-
Notifications
You must be signed in to change notification settings - Fork 477
Add reconnectable websocket manager #192
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
base: master
Are you sure you want to change the base?
Add reconnectable websocket manager #192
Conversation
The previous commit mistakenly modified the original send_ping() method in WebsocketManager. This change restores the method to its original implementation so that the base class remains unmodified. This ensures that the upcoming PR for ReconnectableWebsocketManager remains self-contained and does not alter the behavior of the original WebsocketManager.
|
In the WebsocketManager constructor, the ws_url variable is not stored as an instance field (no self.ws_url). |
|
I'm having hard time not being able to recover from lost connection too. The Also we can't catch the exception in any way, like as in: def main():
#app = HyperLiquidApp()
#app.run()
while run:
try:
address, info, exchange = utils.setup(constants.MAINNET_API_URL, skip_ws=False)
except WebSocketException:
continueSo one alternative should be offered by the this library. I'm waiting to a solution, thank you !! |
|
I'm surprised of how an important piece of software, from a top 10 biggest blockchain is so badly written and barely maintained. It makes me scare of even use Hyperliquid, because if their public library is that bad, I imagine how it would be their private/hidden code. Without the ability to recover from errors, we can't do any professional grade software with this SDK. Even Avantis, which is nothing compared to Hyperliquid, offer an |
|
I hope the Hyperliquid team will accept this PR. I constantly get closed connection. Thank you for the PR @USEONGEE . |
|
I think this solution is more robust: #255 |
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).