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

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

Closed
lsapan opened this issue May 10, 2021 · 1 comment
Closed

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

lsapan opened this issue May 10, 2021 · 1 comment
Assignees
Labels

Comments

@lsapan
Copy link
Sponsor

lsapan commented May 10, 2021

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.

@miguelgrinberg
Copy link
Owner

Looking at that bug fix it seems I only implemented this so that it works with multiple servers. It appears I forgot to implement the disconnect method for the pub/sub manager classes. I'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants