From 0a071a2285a6f50877bac19c9a29a3ad5b2d8b6d Mon Sep 17 00:00:00 2001 From: Blallo Date: Tue, 14 Mar 2023 18:37:49 +0100 Subject: [PATCH] Tentative fix for websocket timeout --- cmd/broadcast/ws_handler.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/broadcast/ws_handler.go b/cmd/broadcast/ws_handler.go index c8a3633..d18a553 100644 --- a/cmd/broadcast/ws_handler.go +++ b/cmd/broadcast/ws_handler.go @@ -50,7 +50,14 @@ func (h *livenessHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { <-ticker.C timer := time.NewTimer(livenessTimeout) select { - case <-timer.C: + case <-r.Context().Done(): + h.logger.Warn(map[string]any{ + "msg": "Liveness context canceled", + "context": "ws", + "err": r.Context().Err(), + }) + return + case <-ticker.C: h.logger.Warn(map[string]any{ "msg": "Liveness request timed out", "context": "ws",