Skip to content

Get list of sockets in the same room when using redis as the adapter (multiple socket.io instances) #2429

@spinwang

Description

@spinwang

I have socket.io running on multiple servers and uses redis as the adapter. I am trying to access all the sockets in one room and see if the room is empty, but I couldn't find all the sockets connected to different servers, though they are in the same room.

var io
io = socket_io(server);
io.adapter(redis({ host: 'localhost', port: 6379 }));
io.nsps['/'].adapter.rooms[roomName] #returns undefined 

# this doesn't work either, always complain 'clients' is undefined, thus can't be used as a function
io.of('/').in(roomName).clients(function(error, clients){
    if (error) throw error;
    console.log(clients); 
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions