From c91cb73e212e249feeaf4b49b4d205b66afec99d Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Thu, 21 Nov 2024 19:38:13 +0100 Subject: [PATCH] XXX add ping fail debug log --- internal/websocket/staleClients.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/websocket/staleClients.go b/internal/websocket/staleClients.go index 5468703..bda334d 100644 --- a/internal/websocket/staleClients.go +++ b/internal/websocket/staleClients.go @@ -16,12 +16,10 @@ func RemoveStaleClients() { for range ticker.C { mu.Lock() for _, client := range Clients { - ping := sendPing(client) - stale := isStale(client) - if !ping || stale { + if !sendPing(client) || isStale(client) { client.Conn.Close() delete(Clients, client.Conn.LocalAddr()) - helper.Logger.Info("Removed stale client", "host", client.RealIP, "lastPong", client.LastPong.Format("RFC3339")) + helper.Logger.Info("Removed stale client", "host", client.RealIP, "lastPong", client.LastPong) } } mu.Unlock() @@ -33,6 +31,7 @@ func sendPing(client *models.WebsocketClient) bool { err := client.Conn.WriteMessage(websocket.PingMessage, nil) if err != nil { + helper.Logger.Debug("ping failed", "host", client.RealIP) return false }