Sometimes, we want to get the Socket.IO connected user count.
In this article, we’ll look at how to get the Socket.IO connected user count.
How to get the Socket.IO connected user count?
To get the Socket.IO connected user count, we can use the socketIO.engine.clientsCount
property.
We can also use
io.sockets.sockets.length
or
Object.keys(io.sockets.connected).length
to get the connected user count.
Conclusion
To get the Socket.IO connected user count, we can use the socketIO.engine.clientsCount
property.