LUCIT-Systems-and-Development / unicorn-binance-websocket-api

A Python SDK by LUCIT to use the Binance Websocket API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, com-coin_futures, us, tr, dex/chain+testnet) in a simple, fast, flexible, robust and fully-featured way.
https://unicorn-binance-websocket-api.docs.lucit.tech/
Other
692 stars 164 forks source link

Errors during listen key keep-alive silently ignored #301

Closed hiliev closed 1 year ago

hiliev commented 1 year ago

Version of this library.

1.41.0

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

Hardware?

VPS or other cloud hosting

Operating System?

Linux

Python version?

Python3.8

Installed packages

unicorn-binance-rest-api==1.4.3
unicorn-binance-websocket-api==1.41.0

Logging output

2022-12-07 13:25:02,404 [INFO    ] restclient: BinanceWebSocketApiRestclient.get_listen_key() stream_id='bd9193b30701-dda5-670c-e946-c1166d3f')
2022-12-07 13:25:02,404 [INFO    ] restclient: BinanceWebSocketApiRestclient.keepalive_listen_key(***SECRET_REMOVED***)
2022-12-07 13:25:02,443 [INFO    ] manager: BinanceWebSocketApiManager._frequent_checks() - sent listen_key keepalive ping for stream_id=bd9193b30701-dda5-670c-e946-c1166d3f
2022-12-07 13:55:02,740 [INFO    ] restclient: BinanceWebSocketApiRestclient.get_listen_key() stream_id='bd9193b30701-dda5-670c-e946-c1166d3f')
2022-12-07 13:55:02,740 [INFO    ] restclient: BinanceWebSocketApiRestclient.keepalive_listen_key(***SECRET_REMOVED***)
2022-12-07 13:55:02,753 [CRITICAL] restclient: BinanceWebSocketApiRestclient._request() - error: 9 -  error_msg: ('Connection aborted.', OSError(107, 'Transport endpoint is not connected'))
2022-12-07 13:55:02,753 [INFO    ] manager: BinanceWebSocketApiManager._frequent_checks() - sent listen_key keepalive ping for stream_id=bd9193b30701-dda5-670c-e946-c1166d3f
2022-12-07 14:25:02,453 [INFO    ] main: User Data: {"e": "listenKeyExpired", "E": 1670423102447, "listenKey": "***"}
2022-12-07 14:25:02,454 [INFO    ] main: User Data: {"e": "listenKeyExpired", "E": 1670423102450, "listenKey": "***"}
2022-12-07 14:25:03,042 [INFO    ] restclient: BinanceWebSocketApiRestclient.get_listen_key() stream_id='bd9193b30701-dda5-670c-e946-c1166d3f')
2022-12-07 14:25:03,042 [INFO    ] restclient: BinanceWebSocketApiRestclient.keepalive_listen_key(***SECRET_REMOVED***)
2022-12-07 14:25:03,075 [INFO    ] manager: BinanceWebSocketApiManager._frequent_checks() - sent listen_key keepalive ping for stream_id=bd9193b30701-dda5-670c-e946-c1166d3f

Processing method?

stream_buffer

Used endpoint?

binance.com-futures

Issue

If an error occurs while posting the listen key keep-alive ping, the error is silently ignored, the keep-alive is considered successful, and the failed operation is not retried. As a result, the listen key expires before the next scheduled ping. The library then keeps posting keep-alive pings to the now defunct listen key.

nand0san commented 1 year ago

similar here when using just one depth stream

oliver-zehentleitner commented 1 year ago

similar here when using just one depth stream

Could you explain that? depth stream is not using a listen key...

oliver-zehentleitner commented 1 year ago

I set the interval from 30 to 10 min in the next release.

But we definitely have to improve this!

oliver-zehentleitner commented 1 year ago

Any news here? Did the last update avoid this issue?

hiliev commented 1 year ago

Looks like bringing the ping interval down to 10 mins has solved the issue for me.

oliver-zehentleitner commented 1 year ago

Cool! We can do it better if needed. lets look how this works long term.

I close this, please reopen or open a new one if needed.