-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieving number of connected sockets using fetchSockets
without getting all socket information
#515
Comments
Hi! Yes, as you have noted the You should use the io.serverSideEmit("hello", "world");
// And on the receiving side:
io.on("hello", (arg1) => {
console.log(arg1); // prints "world"
}); Reference: https://socket.io/docs/v4/server-instance/#serversideemit |
Yeah. I have used that for now. @darrachequesne What do you think about adding the "count" as a separate function? You don't think it would be usable? I have also an example of a patch with a new function. |
I'm not sure that's a good idea, because in most cases I think one wants to count the number of users, not the number of sockets (since a single user can have multiple connections). What do you think? |
I second this. I do not care if socket count is not always 1 to 1 with user count. I need a way to count sockets without pulling all data over the wire. |
@darrachequesne - Sometimes I actually more interested in the sockets as opposed to the users as @cody-evaluate mentioned. An example (my case) for that is for horizontal scaling purposes |
Hi,
We will need to add a function with the functionality mentioned in the title
(Retrieving number of connected sockets using
fetchSockets
without getting all socket information)Currently, in high loaded systems, we have too much traffic in redis since each handshake of a socket contains a lot of information (all the headers, the session info, etc)
Thanks.
I will try to push a PR soon.
The text was updated successfully, but these errors were encountered: