I'm using socket.io in a browser based project where io() is called in the client-side code to start a socket connection to the host server.
var socket = io();
socket.on('connect', () => {
// ...
}
The issue I'm having is that a user can easily open up the console and call io() several times, resulting in multiple socket connections to the server. The socket.io client documentation confirms that when io() is called multiple times, a distinct connection to the server is made.
Is there any way for me to prevent this from being possible?
I would prefer if this was prevented on the client-side but I'm happy to try out server-side solutions as well.
I've tried searching around but most questions like this are about multiple connections accidentally being opened when refreshing the page or similar, I want to stop users from purposefully opening the console and creating new connections.
I was hoping there was some way to hide the io() from the console but any solution would be appreciated.
EDIT: I've been told that the client should not be trusted with this as users can't be stopped from using the console. In that case, I want the server to be able to stop multiple connections coming from one window or device. How would I go about doing that?
Thanks for the help.