unicorn-binance-websocket-api icon indicating copy to clipboard operation
unicorn-binance-websocket-api copied to clipboard

websocket crashes regularly

Open nikky78 opened this issue 2 years ago • 1 comments

Version of this library.

unicorn-binance-websocket 1.41.0

wss = BinanceWebSocketApiManager(
            exchange="binance.com-futures",
            show_secrets_in_logs=True,
            high_performance=True
)

userdata_stream_id = wss.create_stream(
            "arr",
            "!userData",
            api_key=key,
            api_secret=secret,
            stream_label='userData',
            output="dict",
            ping_interval=10, ping_timeout=10, close_timeout=5
)
user_thread = threading.Thread(
                target=callback_user_data_event,
                args=(wss,)
)
user_thread.start()
wss.wait_till_stream_has_started(userdata_stream_id)

Solution to Issue cannot be found in the documentation or other Issues and also occurs in the latest version of this library.

  • [X] I checked the documentation and other Issues. I am using the latest version of this library.

Hardware?

Local server/workstation

Operating System?

Windows

Python version?

Python3.9

Installed packages

No response

Logging output


22 Jun 22 17:44:52 - unicorn_binance_websocket_api - DEBUG - BinanceWebSocketApiManager.set_socket_is_not_ready(1ac92630ef63-4949-7997-2962-2121282d) - called by File "unicorn_binance_websocket_api\manager.py", line 3417, in set_socket_is_not_ready
    logger.debug(f"BinanceWebSocketApiManager.set_socket_is_not_ready({stream_id}){self.get_debug_log()}")
22 Jun 22 17:44:52 - unicorn_binance_websocket_api - DEBUG - BinanceWebSocketApiManager.is_stop_request(1ac92630ef63-4949-7997-2962-2121282d) - called by File "unicorn_binance_websocket_api\manager.py", line 2697, in is_stop_request
    logger.debug(f"BinanceWebSocketApiManager.is_stop_request({stream_id}){self.get_debug_log()}")
22 Jun 22 17:44:52 - unicorn_binance_websocket_api - DEBUG - BinanceWebSocketApiManager.is_stop_request(1ac92630ef63-4949-7997-2962-2121282d) - called by File "unicorn_binance_websocket_api\manager.py", line 2697, in is_stop_request
    logger.debug(f"BinanceWebSocketApiManager.is_stop_request({stream_id}){self.get_debug_log()}")
22 Jun 22 17:44:53 - unicorn_binance_websocket_api - DEBUG - BinanceWebSocketApiManager.set_heartbeat(1ac92630ef63-4949-7997-2962-2121282d)
22 Jun 22 17:44:53 - unicorn_binance_websocket_api - DEBUG - BinanceWebSocketApiManager.is_stop_request(1ac92630ef63-4949-7997-2962-2121282d) - called by File "unicorn_binance_websocket_api\manager.py", line 2697, in is_stop_request
    logger.debug(f"BinanceWebSocketApiManager.is_stop_request({stream_id}){self.get_debug_log()}")
22 Jun 22 17:44:53 - unicorn_binance_websocket_api - DEBUG - BinanceWebSocketApiManager.is_stop_as_crash_request(1ac92630ef63-4949-7997-2962-2121282d) - called by File "unicorn_binance_websocket_api\manager.py", line 2719, in is_stop_as_crash_request
    f"){self.get_debug_log()}")
22 Jun 22 17:44:53 - unicorn_binance_websocket_api - DEBUG - BinanceWebSocketApiManager.set_heartbeat(1ac92630ef63-4949-7997-2962-2121282d)
22 Jun 22 17:44:55 - unicorn_binance_websocket_api - DEBUG - BinanceWebSocketApiSocket.start_socket(1ac92630ef63-4949-7997-2962-2121282d, ['arr'], ['!userData'] - Received inner asyncio.TimeoutError
22 Jun 22 17:44:55 - unicorn_binance_websocket_api - DEBUG - BinanceWebSocketApiManager.is_stop_request(1ac92630ef63-4949-7997-2962-2121282d) - called by File "unicorn_binance_websocket_api\manager.py", line 2697, in is_stop_request
    logger.debug(f"BinanceWebSocketApiManager.is_stop_request({stream_id}){self.get_debug_log()}")
22 Jun 22 17:44:55 - unicorn_binance_websocket_api - DEBUG - BinanceWebSocketApiManager.is_stop_as_crash_request(1ac92630ef63-4949-7997-2962-2121282d) - called by File "unicorn_binance_websocket_api\manager.py", line 2719, in is_stop_as_crash_request
    f"){self.get_debug_log()}")
22 Jun 22 17:44:55 - unicorn_binance_websocket_api - DEBUG - BinanceWebSocketApiManager.set_heartbeat(1ac92630ef63-4949-7997-2962-2121282d)

Processing method?

process_stream_data

Used endpoint?

binance.com-futures

Issue

I am opening a user stream websocket, and right away I get the errors above.

nikky78 avatar Jun 20 '22 19:06 nikky78

Anyone knows why I get those errors?

nikky78 avatar Jun 24 '22 12:06 nikky78

Dont use high_performance=True with only one stream!

Do it this way:

from unicorn_binance_websocket_api.manager import BinanceWebSocketApiManager


def callback_user_data_event(stream_data, stream_buffer_name=False):
    print(f"{stream_data}")


ubwa = BinanceWebSocketApiManager(exchange="binance.com-futures")
ubwa.create_stream("arr",
                   "!userData",
                   api_key=key,
                   api_secret=secret,
                   stream_label='userData',
                   output="dict",
                   ping_interval=10, 
                   ping_timeout=10, 
                   close_timeout=5, 
                   process_stream_data=callback_user_data_event)

oliver-zehentleitner avatar Mar 04 '23 01:03 oliver-zehentleitner