I keep track the list of every users connected in the array. So if there is a new connection, it will check whether the user is already on the list or not, if he was already on
socket.id is used internally by socket.io for its own socket list. You cannot overwrite that or you break some of its ability to maintain its own data structures.
You have two choices:
socket.id value as is (without overwriting it) so you don't break existing behavior. It is already guaranteed to be unique on the server.socket.userId and then you won't conflict.If you need to, you can maintain a map between your own custom id and the socket.io socket.id so you could get to one from the other.
Similar question here: Socket.io custom client ID