Python Websocket Reconnect Examples?

Hi everyone,

I’m using a WeeWX Websocket driver for the tempest for a while now and have been running into some issues around periodic disconnects. They happen once every couple days or so and shouldn’t be a surprise at all, that’s not a concern given the server team needs to be able to deploy, start/stop their services etc…

What I AM struggling with is a good way, via Python, to capture the disconnect and reconnect. I’m using the websocket-client module. I’ve written a simple server to test the exception thrown and wrote some fairly simple reconnect code but given the prod disconnects are infrequent the process of testing it is going slow.

I was curious if anyone else has run into this and has a good solution that they’d be willing to share. I’m more than happy to to peruse a repo if need be. I’d look for the right amount of reconnect and then back-off tries that tend to work.

Any suggestions/thoughts?

Billy