I use websocket establish connect 10000 clients to the server. But when some of the clients disconnect the conn, the server could not find this situation and still keep this conn.So when clients conn to server again,a new conn established and the number of conn in the server become such a large num.If i dont restart the server, the conn num will still imcrease...
Your server websockets have callbacks for error as well as close. Are you monitoring both?
Sockets do not have to tell the other end. Naturally because you can close a browser window and the server will never know. When you open them you can set a time-out that will cause the socket to close if it doesn't see activity in that time.
You could also 'ping' the connections to force and error/close if they disconnect.
Lastly you could have a session GUID that both the client and browser know about (cookie or localStorage). If a client reconnects and the GUID shows an active connection on the server you can close that connection before opening a fresh one.
when using Websocket establish connections, sometimes clients free the conn,but the server didnt