Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我一直在随机断开 websocket。
我的堆栈是:
我不确定其他人是否经历过这种情况。
通常客户端会完美地工作,然后随机地,它会经历断开连接。任何帮助或见解将不胜感激。
为什么不定期从客户端向服务器发送Ping帧(或未经请求的Pong帧)以保持 WebSocket 连接?默认情况下,许多服务器实现会自动断开空闲连接。
Websocket4Net 具有自动 ping 功能。为您的服务器适当地设置 EnableAutoSendPing 和 AutoSendPingInterval。
https://github.com/kerryjiang/WebSocket4Net/blob/042ff279bfb5e9eabe3920452b372bf12c82636c/WebSocket4Net/WebSocket.cs#L38