如果websocket 因为某些原因断开之后怎么重连呢?
def on_close():
print(‘close’)
my_client = UMFuturesWebsocketClient(on_message=message_handler, on_close=on_close)
这个close方法里面应该怎么写呢?或者有没有其他办法实现重新建立链接
如果websocket 因为某些原因断开之后怎么重连呢?
def on_close():
print(‘close’)
my_client = UMFuturesWebsocketClient(on_message=message_handler, on_close=on_close)
这个close方法里面应该怎么写呢?或者有没有其他办法实现重新建立链接
on_close
is a parameter for you to place your callback to handle the close signal from the connection.
If there’s unexpected errors with the connection, you should look into on_error
as well.
Looking at the source code, you can notice that UMFuturesWebsocketClient is inheriting from BinanceWebsocketClient, where self.socket_manager.start()
is located.
This means that, for you to restarted the connection, you need to restart the UMFuturesWebsocketClient
.