Does fetchSockets return all sockets from all nodes? #4513
-
We're using @socket.io/redis-adapter because we're running socket.io on 4 dynos/nodes and we want this to work in a horizontally scalable way. We need to fetch all the sockets in a particular room regardless of the dyno/node they connected to. The question: Does |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@nicholaswmin yes it does! You can also use the // all sockets across all nodes
const allSockets = await io.in("room1").fetchSockets();
// all sockets on the node
const sockets = await io.local.in("room1").fetchSockets(); Reference: https://socket.io/docs/v4/server-api/#serverfetchsockets |
Beta Was this translation helpful? Give feedback.
@nicholaswmin yes it does! You can also use the
local
flag if you need it:Reference: https://socket.io/docs/v4/server-api/#serverfetchsockets