fix: websocket connections unreliable

Constant disconnection and reconnection every couple minutes or less.
This commit is contained in:
talksik
2026-04-09 16:18:38 -07:00
parent 5ea8476f54
commit 66aec4478f
3 changed files with 38 additions and 1 deletions
+2 -1
View File
@@ -38,9 +38,10 @@ func (c *Conn) ReadPump(ctx context.Context, hub *Hub) {
_, data, err := c.ws.Read(ctx)
if err != nil {
if ctx.Err() != nil {
slog.Info("websocket context cancelled", "connId", c.id, "humanId", c.humanID, "error", ctx.Err())
return
}
slog.Debug("websocket read error", "connId", c.id, "error", err)
slog.Info("websocket read error", "connId", c.id, "humanId", c.humanID, "error", err)
return
}
+18
View File
@@ -80,6 +80,24 @@ spec:
---
# WebSocket connections need a much longer timeout than the default 30s.
# Without this, GKE terminates idle WS connections after 30 seconds.
apiVersion: networking.gke.io/v1
kind: GCPBackendPolicy
metadata:
name: pusher-backend-policy
spec:
default:
timeoutSec: 60
connectionDraining:
drainingTimeoutSec: 30
targetRef:
group: ""
kind: Service
name: pusher
---
apiVersion: networking.gke.io/v1
kind: HealthCheckPolicy
metadata:
+18
View File
@@ -77,6 +77,24 @@ spec:
---
# WebSocket connections need a much longer timeout than the default 30s.
# Without this, GKE terminates idle WS connections after 30 seconds.
apiVersion: networking.gke.io/v1
kind: GCPBackendPolicy
metadata:
name: pusher-backend-policy
spec:
default:
timeoutSec: 60
connectionDraining:
drainingTimeoutSec: 30
targetRef:
group: ""
kind: Service
name: pusher
---
apiVersion: networking.gke.io/v1
kind: HealthCheckPolicy
metadata: