user3577360 user3577360 - 2 months ago 7x
Node.js Question

Listing all the clients connected to a room in version > 1

After the io.sockets.clients() method has been depreciated from the later versions of, and after my research couldn't find any documentation on the offical web.

Morever, it gives the type error for clients() method as below:

TypeError: undefined is not a function

Has anyone figured out how to list all the connected clients in a room with the later versions of


To get socket IDs of the clients connected to a room use this code:

var namespace = '/';
var roomName = 'my_room_name';
for (var socketId in io.nsps[namespace].adapter.rooms[roomName]) {


To get socket by socket ID you may try this:

var socket = io.sockets.connected[socketId];