Replies: 2 comments 6 replies
-
You'll probably want to set up Postgres or some other sort of persistent thing and use that to communicate between all of your hosts (e.g. LISTEN/NOTIFY) |
Beta Was this translation helpful? Give feedback.
2 replies
-
@xiki808 go with Redis pubsub or streams. You can also check broadcaster project that supports multiple pubsub servers and have an example you look for in docs |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have encountered an issue where I figured I cannot send a message to all websocket clients connected, but instead only to the clients that have connected to the same worker, when serving the project on gunicorn with multiple workers.
In my project users can connect to a websocket connection for certain features, while using RESTful api for other features. Each time a client connects, I'm storing the websocket client in an array for later use. When one client triggers a feature, I want to send a websocket message to all the clients, but instead only clients connected to the same worker are receiving the message. Later I figured this is happening because in each worker the array of websocket clients is not the same, and it is based on which worker the client got connected to. So far in order to mitigate this is to limit gunicorn wokers down to 1.
Can someone tell me what I can do to be able to send all websocket clients from all workers?
One solution I tried is to have a separate project
A
, which runs on one worker, and the main projectB
( running multiple workers ) will send to the other projectA
the websocket clients that connect to projectB
. Then projectA
receives the websocket client fromB
and send to all clients whenB
tells it to. The problem is that I couldn't figure how to send the websocket client object over from projectB
to projectA
Beta Was this translation helpful? Give feedback.
All reactions