Skip to content

Commit

Permalink
Changed few LOG messages, fixed sio connection issue (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonKirill authored Oct 30, 2024
1 parent abdd8a3 commit c130e86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
2 changes: 2 additions & 0 deletions chat_server/server_utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 7 additions & 14 deletions services/klatchat_observer/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ChatObserver(MQConnector):
"""Observer of conversations states"""

recipient_prefixes = {
Recipients.NEON: ["neon", "@neon"],
Recipients.NEON: ["neon"],
Recipients.UNRESOLVED: ["undefined"],
}

Expand Down Expand Up @@ -340,32 +340,26 @@ 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):
"""
Creates socket io client if none is present
:return: connected async socket io instance
"""
if not self._sio:
if not (self._sio or self._sio.connected):
self.connect_sio()
return self._sio

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()

Expand Down Expand Up @@ -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}"
Expand Down

0 comments on commit c130e86

Please sign in to comment.