avoid closing connection on pong error
This commit is contained in:
@@ -41,15 +41,14 @@ func (c *Conn) ReadPump(ctx context.Context, hub *Hub) {
|
|||||||
slog.Info("websocket context cancelled", "connId", c.id, "humanId", c.humanID, "error", ctx.Err())
|
slog.Info("websocket context cancelled", "connId", c.id, "humanId", c.humanID, "error", ctx.Err())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
slog.Info("websocket read error", "connId", c.id, "humanId", c.humanID, "error", err)
|
slog.Warn("websocket read error", "connId", c.id, "humanId", c.humanID, "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Respond to keep-alive pings
|
// Respond to keep-alive pings
|
||||||
if string(data) == "ping" {
|
if string(data) == "ping" {
|
||||||
if err := c.ws.Write(ctx, websocket.MessageText, []byte("pong")); err != nil {
|
if err := c.ws.Write(ctx, websocket.MessageText, []byte("pong")); err != nil {
|
||||||
slog.Debug("websocket pong write error", "connId", c.id, "error", err)
|
slog.Warn("websocket pong write error", "connId", c.id, "error", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user