diff --git a/SmartApi/smartWebSocketV2.py b/SmartApi/smartWebSocketV2.py index e2da92c9..02fef748 100644 --- a/SmartApi/smartWebSocketV2.py +++ b/SmartApi/smartWebSocketV2.py @@ -315,6 +315,11 @@ def close_connection(self): def _on_error(self, wsapp, error): self.RESUBSCRIBE_FLAG = True + + # Don't reconnect if DISCONNECT_FLAG is True + if self.DISCONNECT_FLAG: + return False + if self.current_retry_attempt < self.MAX_RETRY_ATTEMPT: logger.warning(f"Attempting to resubscribe/reconnect (Attempt {self.current_retry_attempt + 1})...") self.current_retry_attempt += 1