diff --git a/chat_server/server_utils/auth.py b/chat_server/server_utils/auth.py index 50833a00..f04c12a5 100644 --- a/chat_server/server_utils/auth.py +++ b/chat_server/server_utils/auth.py @@ -196,6 +196,8 @@ def get_current_user_data( session = refresh_session(payload=payload) LOG.info("Session was refreshed") user_data = UserData(user=user, session=session) + except jwt.DecodeError as ex: + LOG.info(f"Invalid session token: {ex}") except BaseException as ex: LOG.exception( f"Problem resolving current user: {ex}\n" diff --git a/services/klatchat_observer/controller.py b/services/klatchat_observer/controller.py index 42ace1b5..381140de 100644 --- a/services/klatchat_observer/controller.py +++ b/services/klatchat_observer/controller.py @@ -60,7 +60,7 @@ class ChatObserver(MQConnector): """Observer of conversations states""" recipient_prefixes = { - Recipients.NEON: ["neon", "@neon"], + Recipients.NEON: ["neon"], Recipients.UNRESOLVED: ["undefined"], } @@ -340,15 +340,6 @@ def connect_sio(self): ) self.register_sio_handlers() - def reconnect_sio(self): - """ - Method for reconnecting to the Socket IO server - """ - if self._sio is not None: - self._sio.disconnect() - self.connect_sio() - return self._sio - @property def sio(self): """ @@ -356,7 +347,7 @@ def sio(self): :return: connected async socket io instance """ - if not self._sio: + if not (self._sio or self._sio.connected): self.connect_sio() return self._sio @@ -364,8 +355,11 @@ def _handle_auth_expired(self, data: dict): handler = data["handler"] status = data["status"] error = data["body"] - LOG.error( - f"({status}) Failed to authorize response for {handler=!r}, {error=!r}" + LOG.info( + "Failed to authorize response for klat server", + status=status, + handler=handler, + error=error, ) self._login_to_klat_server() @@ -844,7 +838,6 @@ def _login_to_klat_server(self): ) if response.ok: self._klat_session_token = response.json()["token"] - self.reconnect_sio() else: LOG.error( f"Klat API authorization error: [{response.status_code}] {response.text}"