How to fix {'e': 'error', 'm': 'Max reconnect retries reached'}

Hello,
is there an example in python how to reconnect after I lose websocket stream with this error? My problem is that I detect this message within order_handler, so I cannot call “ws_client.user_data(listen_key=response[“listenKey”],id=0,callback=order_handler)” from within callback function

Thanks very much, Jan

When dealing with WebSockets, you associate different callbacks to different received data.
If there’s an error, you associate it with a "on error callback ".
I helps, you can take a look at binance’s python connector’s code for Websocket Managing at https://github.com/binance/binance-connector-python/blob/master/binance/websocket/binance_socket_manager.py