[英]when using Websocket establish connections, sometimes clients free the conn,but the server didnt
I use websocket establish connect 10000 clients to the server. 我使用websocket建立将10000个客户端连接到服务器。 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...
但是,当某些客户端断开conn连接时,服务器无法找到这种情况,并且仍然保留此conn。因此,当客户端再次连接到服务器时,将建立一个新的conn,并且服务器中的conn数量将变得如此之大。我不重新启动服务器,连接数仍然会增加...
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. 如果它们断开连接,也可以“ ping”连接以强制和错误/关闭。
Lastly you could have a session GUID that both the client and browser know about (cookie or localStorage). 最后,您可以拥有一个客户端和浏览器都知道的会话GUID(cookie或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.
如果客户端重新连接并且GUID显示服务器上的活动连接,则可以在打开新连接之前关闭该连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.