Categories
JavaScript Answers

How to get the Socket.IO connected user count?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *