how to get users in a socket.io room using redis-socket.io in a pm2 cluster


I have been looking for a solution to this but as of yet have not found one. As the title says, we are using socket.io, redis-socket.io and pm2 cluster for a chat application. This is working well however grabbing the users in a specific room only grabs the users on the node you are on.

I have seen some responses that say you can track the sockets via redis however those solutions are a few years old so I was hoping there may be a built in solution as part of the redis-socket.io project that I’m not aware of.

Essentially when a user connects to a room we call

socketID in io.nsps['/'].adapter.rooms[room].sockets

This gives us an object of all the users in that room, however in a cluster it only grabbing the users on that node so some are left out.

Any help would be appreciated.

Thanks.