Closed ashwinvenkatram closed 3 years ago
Hello!
This depends on the maintenance task of Binance. In most cases I just receive nothing but stay connected. After a while trading continues and also the stream does. Its also possible that the connection to API endpoints can not get established till maintenance is over - in such a case you are disconnected.
There is no exception for maintenance windows, only for a non repairable webstream (wrong api key or something else) and this exception is only thrown if you set throw_exception_if_unrepairable=True
If you want to get a notification if the status of the websocket connection changes you can use the stream_signal_buffer
Exception handling is in https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/blob/master/unicorn_binance_websocket_api/unicorn_binance_websocket_api_socket.py
Best regards!
Hi Oliver,
Thanks for sharing the expected behaviour of the websocket. It's interesting that the behaviour can change depending on the maintenance task of Binance! I was under the impression any time the "Service down for maintenance" exception is encountered, the behaviour is always the same.
In my case, I was running a test of my program and computes indicator data for every minute of OHLCV data. From my logs, I found that the indicator data was being computed although the service was down for maintenance. The values converged and remained steady during the maintenance period. This seems to indicate that the websocket was actually alive, and Binance in this case, was sending me the last frozen OHLCV data when maintenance was triggered.
The notification of status change on the websocket is definitely helpful.
Thank you!
Your welcome!
Hello,
I am using this API to interface with Binance USDT-M Futures.
Earlier today I encountered a "Service under Maintenance" exception when Binance triggered their scheduled system update. I came across a comment in the documentation which states this is being handled internally. I'm curious to know more about how this exception is being handled and the websocket behaviour.
For some context, my program is running two processes in parallel. First, an instance of the websocket from this API which places klines data on a queue once a specified interval is complete. A 2nd process then reads this data to perform post processing.
My questions are:
Thanks very much.