mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-06-28 21:58:17 +08:00
fix(msggateway): reset read deadline in pong handler to prevent Web client timeout
Root cause: Due to browser API restrictions, Web (Wasm) clients cannot actively send standard WebSocket Ping frames. They rely entirely on server-initiated Pings (every 27s) and automatic browser Pong responses to maintain the connection. The `pongHandler` was empty and failed to reset the connection's read deadline upon receiving a Pong, causing the server's read loop to strictly time out at 30 seconds. Solution: Call `c.setReadDeadline()` inside the `pongHandler` to properly extend the connection's lifespan when a Pong frame is received.
This commit is contained in:
parent
c66b2d95ad
commit
90a222bfec
@ -208,7 +208,11 @@ func (c *websocketClientConn) pingHandler(appData string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *websocketClientConn) pongHandler(string) error {
|
||||
func (c *websocketClientConn) pongHandler(appData string) error {
|
||||
log.ZDebug(context.Background(), "pong handler recv pong", "remoteAddr", c.conn.RemoteAddr(), "appData", appData)
|
||||
if err := c.setReadDeadline(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user