bybit-exchange / pybit

Official Python3 API connector for Bybit's HTTP and WebSockets APIs.
Other
418 stars 135 forks source link

Closed WebSocket doesn't stop pinging #252

Open nietsuu opened 1 day ago

nietsuu commented 1 day ago

Pseudocode:

ws = unified_trading.WebSocket()
ws.exit()

The websocket closes just fine. But it throws nonstop errors afterwards because the websocket is still trying to ping even though it's already closed.

This should be fixed easily in the _WebSocketManager._send_custom_ping method by checking if the ws is already closed.

nietsuu commented 1 day ago

Upon further debugging, its not actually sending pings "nonstop". It only sends 2 pings then stop. However, this still should be not the case. It should stop sending pings right away.

nietsuu commented 1 day ago

My guess is that this is actually a problem of the websocket-client library and not pybit. I'll keep investigating.