fix: Stop bybit websocket stream ping timer on disconnect
This commit is contained in:
1 parent
6448b4cf90
commit
804c27eb49
1 file changed
+7
-2
@@ -69,6 +69,7 @@ class _WebSocketManager:
|
||||
self.subscriptions = []
|
||||
|
||||
# Set ping settings.
|
||||
self._ping_timer: Optional[threading.Timer] = None
|
||||
self.ping_interval = ping_interval
|
||||
self.ping_timeout = ping_timeout
|
||||
self.custom_ping_message = json.dumps({"op": "ping"})
|
||||
@@ -264,10 +265,12 @@ class _WebSocketManager:
|
||||
|
||||
def _send_initial_ping(self):
|
||||
"""https://github.com/bybit-exchange/pybit/issues/164"""
|
||||
timer = threading.Timer(
|
||||
if self._ping_timer:
|
||||
self._ping_timer.cancel()
|
||||
self._ping_timer = threading.Timer(
|
||||
self.ping_interval, self._send_custom_ping
|
||||
)
|
||||
timer.start()
|
||||
self._ping_timer.start()
|
||||
|
||||
@staticmethod
|
||||
def _is_custom_pong(message):
|
||||
@@ -284,6 +287,8 @@ class _WebSocketManager:
|
||||
self.exited = False
|
||||
self.auth = False
|
||||
self.data = {}
|
||||
if self._ping_timer:
|
||||
self._ping_timer.cancel()
|
||||
|
||||
def exit(self):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user