Replies: 2 comments 22 replies
-
All of this can be implemented in the onConnect and onClose hooks. A map of token with the sockets array should suffice. When a token appears, look up the map, and if the sockets array exceeds the size, simply You of course have to get the "number of allowed sockets" right, users open multiple tabs when working and can therefore establish multiple, valid, connections. What's the thing you want to achieve, protect against excess connections from a single device, or across all devices? |
Beta Was this translation helpful? Give feedback.
-
I added a class for keeping track of the connections:
Then
Btw if i call Also, im now keeping the sockets in memory with my set. I wonder if this may lead to memory leaks? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Somewhat related to #489 that tries to avoid troubles with clients we have no control over: we've previously limited number of connections single user can open on a server by tracking their authorization tokens and blocking at onConnect if there already are 2 sockets for a token.
This has proven problematic as there is nothing that would recover the situation where server thinks there are two connections for a user. Im thinking if a better approach could be to track sockets by token but instead or blocking, just close the other sockets for same token when new connection is initialized.
Does this sound like a proper way to protect from excess connections? Any advise on how to implement it on uWs?
Br,
Toni
Beta Was this translation helpful? Give feedback.
All reactions