Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle remote WebSocket disconnections. #121

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

adderthorn
Copy link

Adds a boolean property to the TimelineStreaming class to specify reconnection of a stream if disconnected. This is used with a new try/catch block to gracefully handle a WebSocketException and either stop the stream or attempt a reconnect.

I have been working on an application that uses this library and uses the Web Socket streaming. I found after ~2 hours my remote server would unexpectedly close the connection resulting in a crash. I've solved this myself adding this try/catch to catch the websocket exception and either gracefully close the stream or reconnect depending on a flag.

I'm open to other thoughts on how to handle this, and I'm not sure I love the property on the abstract class, but wanted to keep it simple so that, if there's a solution that works better for the project, it would be easy to change. Let me know what you think.

adderthorn and others added 4 commits March 2, 2024 10:44
Adds a boolean property to the `TimelineStreaming` class to specify reconnection of a stream if disconnected. This is used with a new try/catch block to gracefully handle a `WebSocketException` and either stop the stream or attempt a reconnect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant