Search code examples
pythonflaskflask-socketiopython-socketio

Flask-SocketIO v5.2.0 join_room sid key error when using python-socketio v5.11.2


python-socketio v5.11.2 is causing my flask server (Flask-SocketIO v5.2.0) to create a key error when invoking join_room.

Client first connects, then returns a key error when joining a room.

It seems that the server has not registered the Client's sid?

I'm not seeing this when using python-socketio v5.6.0

Exception in thread Thread-48578:
Traceback (most recent call last):
  File "/usr/local/anaconda/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/local/anaconda/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/anaconda/lib/python3.7/site-packages/socketio/server.py", line 730, in _handle_event_internal
    r = server._trigger_event(data[0], namespace, sid, *data[1:])
  File "/usr/local/anaconda/lib/python3.7/site-packages/socketio/server.py", line 755, in _trigger_event
    return self.handlers[namespace][event](*args)
  File "/usr/local/anaconda/lib/python3.7/site-packages/flask_socketio/__init__.py", line 283, in _handler
    *args)
  File "/usr/local/anaconda/lib/python3.7/site-packages/flask_socketio/__init__.py", line 766, in _handle_event
    ret = handler(*args)
  File "routes.py", line 23, in request_session_data
    join_room(semid)
  File "/usr/local/anaconda/lib/python3.7/site-packages/flask_socketio/__init__.py", line 924, in join_room
    socketio.server.enter_room(sid, room, namespace=namespace)
  File "/usr/local/anaconda/lib/python3.7/site-packages/socketio/server.py", line 436, in enter_room
    self.manager.enter_room(sid, namespace, room)
  File "/usr/local/anaconda/lib/python3.7/site-packages/socketio/base_manager.py", line 124, in enter_room
    eio_sid = self.rooms[namespace][None][sid]
  File "/usr/local/anaconda/lib/python3.7/site-packages/bidict/_base.py", line 530, in __getitem__
    return self._fwdm[key]
KeyError: 'a_dJOzmVenu8VPajAAVt'

Thanks for taking a look. Big fan of Flask-Socketio/python-socketio, please let me know what I can do to help.


Solution

  • It seems that I had removed aiohttp via pip. I don't understand why the missing library wasn't caught, but in this case it was needed to operate properly. Thanks for your help!