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

How to disconnect SIDs from Celery worker #1174

Closed
tropicoo opened this issue Feb 4, 2020 · 2 comments
Closed

How to disconnect SIDs from Celery worker #1174

tropicoo opened this issue Feb 4, 2020 · 2 comments
Assignees

Comments

@tropicoo
Copy link

tropicoo commented Feb 4, 2020

Hey,
Basically I have set up SocketIO (gunicorn + eventlet) + Flask + Celery with Redis as message queue. Emitting from Celery worker works, but how to disconnect people from Celery?

After successful websocket connection and passing JWT authorization token as query param I cache SID to the Redis with JWT access expiration time. I want to disconnect people when expiration time is over, but it seems that Celery worker doesn't have any relationship with Flask/SocketIO server through the Redis (disconnect function).

In Celery task I retrieve SIDs from Redis that should be disconnected.
Is there any workaround for disconnect function?

# Celery worker
expired = self._cache.get_expired_sids()
for sid in expired:
    disconnect(sid, namespace='/n')
    self._cache.delete_sid(sid)

This code should handle case when websocket connection is still alive even when the user auth is expired.
Thanks.

@miguelgrinberg
Copy link
Owner

There is currently no support for disconnecting users from a third party script. Could be added, I'll leave this open as a feature request for that.

@miguelgrinberg
Copy link
Owner

@tropicoo the master branch on the python-socketio repo has this implemented. Could I ask you to install that from the github repo and give it a quick test? The addition is that the client manager object now has a disconnect() method.

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

No branches or pull requests

2 participants