-
Notifications
You must be signed in to change notification settings - Fork 245
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
Need a callback to recover from WebSocketConnectionClosedException #120
Comments
What exactly error log did you receive? |
@2pd Thanks for the response, I'm sharing the error log at the end of this message. For some additional context, I have wrapped Let me know if there's anything else I can provide in order to help. Error Log:
|
I'm having the same issue |
yeah, I got the same issue. Need a way to catch that remote host was lost exception. |
Could we update like this? See my comment in the code below:
|
Any update on this? |
@6ameDev As a temporary solution, I think you can define an infinite loop after you create your WS connection and check the
You should also change the connected property of WS to False when there is an internal exception there. So in BinanceSocketManager add Let me know if this helps so I can create a PR for it. |
I met the same issue for several month, my solution is .... i write a script to check the log file, if this lost word appears, then kill the process and reboot my program: loading histroy data and create the connection, this is a ugly method, I hope anyone give a graceful method |
Guys, check this: #158. |
Hey guys, What I did: except WebSocketException as e:
if isinstance(e, WebSocketConnectionClosedException):
self.logger.error("Lost websocket connection")
else:
self.logger.error("Websocket exception: {}".format(e))
if self.ws.connected:
self.ws.send_close()
self.ws.connected = False
self._callback(self.on_error, e)
break
except Exception as e:
self.logger.error("Exception in read_data: {}".format(e))
if self.ws.connected:
self.ws.send_close()
self.ws.connected = False
self._callback(self.on_error, e)
break |
In
binance/websocket/binance_socket_manager.py
, whenWebSocketException
is caught and identified asWebSocketConnectionClosedException
, it logs that websocket connection is lost.However in that case, I haven't been able to identify a flow where a
on_close
oron_error
callback is triggered, so that it can be handled in the application code, in order to re-establish the websocket connection.Any help regarding this would be highly appreciated. Thanks
The text was updated successfully, but these errors were encountered: