You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using this step by step guide to enable cluster while using socket.io 1.0+.
Now, I can balance connections properly across workers, but I dont know how to pass events across workers.
My use case is simple
Client side, i have sockets connecting to namespaces (per object, e.g : let's assume a user sees a whiteboard).
When first user joins, one of the workers receives a http request and creates a room :
// creating and initializing a room
app.get("socketio").of(roomName).on("connection", function(socket){
// implement the socket behaviour
socket.on("join", ...) ;
})
With cluster enabled, new socket events might be redirected to different workers from the one the handlers where setup. Then, when testing if the room already exists (on any worker), we might miss the fact that the room was already created in another worker:
// testing if a room exists
if (_.keys(app.get("socketio").nsps).indexOf(roomName) == -1) {
// create the room :(
app.get("socketio").of(roomName).on("connection", function(socket){
}
So my questions are :
1- Do you have any idea how we could adapt the code here so that we have a way to test room existence globally across workers ? I've done this by saving room names within a hash in redis, but wanted to know if it is supported by the adapter ?
2-How then to redirect events received from a worker to the actual worker where the handler was setup in? Is it supported also by redis adapter ?
The text was updated successfully, but these errors were encountered:
Hi,
I've been using this step by step guide to enable cluster while using socket.io 1.0+.
Now, I can balance connections properly across workers, but I dont know how to pass events across workers.
My use case is simple
Client side, i have sockets connecting to namespaces (per object, e.g : let's assume a user sees a whiteboard).
When first user joins, one of the workers receives a http request and creates a room :
With cluster enabled, new socket events might be redirected to different workers from the one the handlers where setup. Then, when testing if the room already exists (on any worker), we might miss the fact that the room was already created in another worker:
So my questions are :
1- Do you have any idea how we could adapt the code here so that we have a way to test room existence globally across workers ? I've done this by saving room names within a hash in redis, but wanted to know if it is supported by the adapter ?
2-How then to redirect events received from a worker to the actual worker where the handler was setup in? Is it supported also by redis adapter ?
The text was updated successfully, but these errors were encountered: