You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import time
import socketio
sio = socketio.Client()
@sio.on('connect', namespace='/chat')
def on_connect():
print("I'm connected to the /chat namespace!")
@sio.on('join_event', namespace='/chat')
def on_message(data):
print(f'[join_event]: {data}')
@sio.on('message', namespace='/chat')
def on_message(data):
print(f'I received a message: {data}')
sio.connect('http://127.0.0.1:5000', namespaces=['/chat'])
time.sleep(5)
sio.emit('message', {'foo': 'bar'}, namespace='/chat')
print("sent msg.")
When client connects, server raises following error:
(25100) wsgi starting up on http://0.0.0.0:5000
(25100) accepted ('127.0.0.1', 60310)
127.0.0.1 - - [14/Dec/2020 13:07:17] "GET /socket.io/?EIO=4&transport=polling&t=NPXNBu7 HTTP/1.1" 200 329 0.001411
(25100) accepted ('127.0.0.1', 60312)
connected: jNJJ7jG2LFx5w5YRAAAB
message handler error
Traceback (most recent call last):
File "/home/pata/.pyenv/versions/3.7.7/envs/env/lib/python3.7/site-packages/engineio/server.py", line 606, in _get_socket
s = self.sockets[sid]
KeyError: 'Q2dEwhemB-8GAYSMAAAB'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pata/.pyenv/versions/3.7.7/envs/env/lib/python3.7/site-packages/engineio/server.py", line 595, in _trigger_event
return self.handlers[event](*args)
File "/home/pata/.pyenv/versions/3.7.7/envs/env/lib/python3.7/site-packages/socketio/server.py", line 722, in _handle_eio_message
self._handle_connect(eio_sid, pkt.namespace)
File "/home/pata/.pyenv/versions/3.7.7/envs/env/lib/python3.7/site-packages/socketio/server.py", line 622, in _handle_connect
self.environ[eio_sid])
File "/home/pata/.pyenv/versions/3.7.7/envs/env/lib/python3.7/site-packages/socketio/server.py", line 694, in _trigger_event
return self.handlers[namespace][event](*args)
File "/mnt/c/Users/pata/PycharmProjects/ec-3.0-backend/source/chat_ws/ws.py", line 65, in connect
sio.save_session(sid, {'username': 'dgdfg'}, namespace='/chat')
File "/home/pata/.pyenv/versions/3.7.7/envs/env/lib/python3.7/site-packages/socketio/server.py", line 459, in save_session
eio_session = self.eio.get_session(sid)
File "/home/pata/.pyenv/versions/3.7.7/envs/env/lib/python3.7/site-packages/engineio/server.py", line 231, in get_session
socket = self._get_socket(sid)
File "/home/pata/.pyenv/versions/3.7.7/envs/env/lib/python3.7/site-packages/engineio/server.py", line 608, in _get_socket
raise KeyError('Session not found')
KeyError: 'Session not found'
Output log contains printed sid that was received inside connect() method: connected: jNJJ7jG2LFx5w5YRAAAB
I tried to look inside engineio/server.pyServer._get_socket() method using debugger. There is one record inside self.sockets but it's completely different from what I'm printing inside my connect() method.
The text was updated successfully, but these errors were encountered:
The different sid values is a change introduced in the latest version of the Socket.IO protocol, that is expected. But this may be a bug introduced when I implemented this change.
@pavel-vorobyev the issue reported in this bug is fixed. If you are receiving the same error, please open an issue and provide code that I can use to reproduce the error.
python-socketio==5.0.2
eventlet==0.30.0
Python 3.7.7 on linux (WSL2 Ubuntu 18.04.4 LTS)
I'm trying to run server from the docs using sessions.
My server code:
My client code:
When client connects, server raises following error:
Output log contains printed sid that was received inside
connect()
method:connected: jNJJ7jG2LFx5w5YRAAAB
I tried to look inside
engineio/server.py
Server._get_socket()
method using debugger. There is one record insideself.sockets
but it's completely different from what I'm printing inside myconnect()
method.The text was updated successfully, but these errors were encountered: