Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed few LOG messages, fixed sio connection issue #103

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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