简体   繁体   English

使用Websocket建立连接时,有时客户端会释放conn,但服务器没有

[英]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.

相关问题 使用Python Twisted Websocket客户端建立与服务器的并发Websocket连接 - Establish Concurrent Websocket Connections to server Using Python Twisted Websocket Client 龙卷风 websocket 服务器 - 连接队列 - tornado websocket server - connections queue 并发连接到Tornado WebSocket服务器 - Concurrent connections to Tornado WebSocket server websocket客户端和服务器之间的数据交换 - Data exchange between websocket clients and server WebSocket 服务器拒绝 Django 频道中的所有连接 - WebSocket server refusing all connections in Django Channels 龙卷风可以使用其默认的HTTP服务器支持50个-100个Websocket客户端,而无需涉及ngnix - Can tornado support 50 -100 websocket clients using its default http server without involving ngnix Bottle.py服务器有时即使存在路由也拒绝连接或给出404 - Bottle.py server sometimes refusing connections, or giving 404, even when route exists 无法建立基本的简单flask SocketIO websocket服务器 - Unable to establish a basic simple flask SocketIO websocket server 使用Autobahn / Twisted在Tornado HTTP Handler中建立websocket连接 - Using Autobahn/Twisted to establish a websocket connection in Tornado HTTP Handler Python多线程服务器和与Android客户端的异步Websocket通信 - Python multithreaded server and asynchronuous websocket communication with Android clients
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM