Add reconnectable websocket manager #192
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #191
Title
Add
ReconnectableWebsocketManagerwith automatic reconnection, subscription restoration, and persistent app-level pingSummary
This PR introduces
ReconnectableWebsocketManager, extendingWebsocketManagerto automatically reconnect on disconnection and restore subscriptions after the connection is re-established. It also ensures the application-level ping continues across reconnects.Note
This PR does not modify the original
WebsocketManagerimplementation; all changes are encapsulated in the newReconnectableWebsocketManagerChanges
ReconnectableWebsocketManagerping_timeout,ping_interval, andreconnect_interval.on_close/on_errortrigger reconnection unlessstop_eventis set._reconnect()re-queues previously active subscriptions;on_open()drains the queue and re-subscribes.send_ping()so the ping thread does not terminate when the socket drops; it skips sends while disconnected and resumes automatically after reconnect._start_ping_sender().reconnect_interval.Why
WebsocketManagerdoes not provide reconnection or subscription restoration. This PR improves resilience under network instability and server restarts, and maintains application-level heartbeats across reconnects.Out of Scope
queued_subscriptions,active_subscriptions,subscription_id_counter).