Skip to content

Calling disconnect on a write_only manager doesn't trigger anything #684

@lsapan

Description

@lsapan

Describe the bug
Related to flask-socketio #1174, I needed to be able to disconnect clients by their sid from external processes (such as Celery). Thanks to the work done in flask-socketio #1174 this is possible, but it looks like it may have partially broken somewhere along the way. Calling disconnect on a write_only manager doesn't throw an exception, but nothing happens. I've inspected the messages being sent through redis and it simply isn't sending one. That said, calling can_disconnect or _publish directly both work.

To Reproduce
I have only tested with an AsyncServer and redis, so I'm not sure at the moment if it affects all managers. Note though that the manager I'm calling disconnect on is a sync redis manager.

  1. Set up a server:
import socketio

mgr = socketio.AsyncRedisManager(...)
sio = socketio.AsyncServer(client_manager=mgr, ...)
  1. Set up a write-only manager:
external_sio = socketio.RedisManager(..., write_only=True)
  1. Connect to the SocketIO server and grab the sid (not strictly necessary)
  2. Run external_sio.disconnect('sid_here', namespace='/some_namespace')
  3. Observe that the client isn't disconnected. Furthermore, you'll notice that the pubsub message: disconnect log doesn't show up (see this line). I subclassed the manager and confirmed that nothing was being received at all, so it isn't just getting stopped somewhere in the middle of _thread.

Expected behavior
The disconnect event should be sent through redis.

Logs
No logs, but that's part of the problem 😄

Additional context
Thank you so much for this fantastic library, it's a life saver. To anyone else experiencing this in the meantime, you can use external_sio.can_disconnect instead.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions