From 55f7ecae6b2b45c4c5108aa337eb4c571783d004 Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Thu, 21 Nov 2024 19:35:05 +0100 Subject: [PATCH] update stale logic to always execute ping and stale check --- internal/websocket/staleClients.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/websocket/staleClients.go b/internal/websocket/staleClients.go index f27672d..5468703 100644 --- a/internal/websocket/staleClients.go +++ b/internal/websocket/staleClients.go @@ -16,10 +16,12 @@ func RemoveStaleClients() { for range ticker.C { mu.Lock() for _, client := range Clients { - if sendPing(client) && !isStale(client) { + ping := sendPing(client) + stale := isStale(client) + if !ping || stale { client.Conn.Close() delete(Clients, client.Conn.LocalAddr()) - helper.Logger.Info("Removed stale client", "host", client.RealIP, "lastPong", client.LastPong) + helper.Logger.Info("Removed stale client", "host", client.RealIP, "lastPong", client.LastPong.Format("RFC3339")) } } mu.Unlock()