fix: send pong back to client

avoid disconnections every 2.5 minutes
This commit is contained in:
talksik
2026-04-09 11:42:55 -07:00
parent 7890304639
commit 63eb6aa27f
2 changed files with 8 additions and 1 deletions
+5 -1
View File
@@ -44,8 +44,12 @@ func (c *Conn) ReadPump(ctx context.Context, hub *Hub) {
return
}
// Ignore keep-alive pings
// Respond to keep-alive pings
if string(data) == "ping" {
if err := c.ws.Write(ctx, websocket.MessageText, []byte("pong")); err != nil {
slog.Debug("websocket pong write error", "connId", c.id, "error", err)
return
}
continue
}
+3
View File
@@ -176,6 +176,9 @@ export class PusherClient {
}
private handleMessage(data: string): void {
// Ignore keep-alive pong responses
if (data === "pong") return;
let msg: ServerMessage;
try {
msg = JSON.parse(data);