-
Notifications
You must be signed in to change notification settings - Fork 249
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
add a websocket callback: on_disconnected() #158
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey man, this is awesome. I've monkeypatched it similar in my project, but this is solution which I'm looking for
Does anyone maintain this repo? Quite critical issue is resolved here..... |
Hi @daboooooo , Something like this? 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix the "websocket._exceptions.WebSocketConnectionClosedException: Connection to remote host was lost." issue
Just for your information, the new version of websocket-client introduced a |
Can you point to this in code. Not able to find it in latest |
The latest version is 1.8.0 which already supports this. |
I want to reconnect to websocket server, but can't catch the disconnected exception raised by the BinanceSocketManager thread. So add the on_disconnected() callback to solve this problem.