diff --git a/internal/websocket/staleClients.go b/internal/websocket/staleClients.go index bfa3de9..d7980ac 100644 --- a/internal/websocket/staleClients.go +++ b/internal/websocket/staleClients.go @@ -31,8 +31,14 @@ func RemoveStaleClients() { for range ticker.C { mu.Lock() for _, client := range Clients { - // send ping and check for last pong - if !sendPing(client) || isStale(client) { + // send ping + if !sendPing(client) { + client.Conn.Close() + delete(Clients, client.Conn.LocalAddr()) + } + + // check for last pong + if isStale(client) { client.Conn.Close() delete(Clients, client.Conn.LocalAddr()) }