question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Count of connected clients/sockets

See original GitHub issue

Hi,

I am using io.sockets.clients().length to get the count of all currently connected clients, but after some time this number is way to high, many disconnected clients are still present in this array.

Below an image of io.sockets.clients().length, plotted every 5 minutes for 24 hours. Once the count reached over ~2k, i restarted the server, about 200 to 300 clients reconnected, which is the correct count.

Connected Clients

Is this the wrong way to get the count of all connected clients? I also tried to count the connects and disconnects manually, but after one day there were more disconnects than connects, the count was negative.

Related: https://github.com/LearnBoost/socket.io/issues/349

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:53 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
dmportellacommented, Jul 3, 2012

there is also a Disable notifications for this Issue below

5reactions
dmportellacommented, Jul 3, 2012

man i got to do it +1 to that

Read more comments on GitHub >

github_iconTop Results From Across the Web

Socket.IO Connected User Count - node.js - Stack Overflow
This returns the number of clients connected to my server. The problem is after a few connects and disconnects of users, the number...
Read more >
The Server instance - Socket.IO
A reference to the underlying Engine.IO server. It can be used to fetch the number of currently connected clients: const count = io.engine....
Read more >
Detecting the Number of Connected Socket Users - Medium
Detecting the Number of Connected Socket Users. This post assumes that you have basic knowledge of React and Socket.io, their basic setups, uses ......
Read more >
socket.io.clientsCount JavaScript and Node.js code examples
Best JavaScript code snippets using socket.io.clientsCount(Showing top 6 results out of 315) ; console.log('User ' + client.id + ; io.emit("update-users", io.
Read more >
Scaling Socket.IO - practical considerations - Ably Realtime
As we saw in the performance section of this article, a Socket.IO server can sustain 10,000 concurrent connections. However, this number is only ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found