From 51b54e8f91a4329f7dccaeacdc3726700f5e293b Mon Sep 17 00:00:00 2001 From: elskow Date: Mon, 21 Oct 2024 09:32:55 +0700 Subject: [PATCH] fix: unncessary logging of messages --- videochat-cp/server.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/videochat-cp/server.go b/videochat-cp/server.go index b9e1e69..323f4e0 100644 --- a/videochat-cp/server.go +++ b/videochat-cp/server.go @@ -176,10 +176,11 @@ func (s *Server) handleIncomingMessages(ctx context.Context, c *websocket.Conn, default: _, msg, err := c.ReadMessage() if err != nil { - if websocket.IsCloseError(err, websocket.CloseGoingAway, websocket.CloseNormalClosure) { - return + if websocket.IsCloseError(err, websocket.CloseGoingAway, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) { + logger.Info("WebSocket connection closed", zap.Error(err)) + } else { + logger.Error("Failed to read message", zap.Error(err)) } - logger.Error("Failed to read message", zap.Error(err)) return } @@ -214,7 +215,7 @@ func (s *Server) broadcastMessageToRoom(ctx context.Context, roomID string, send for client := range room.clients { if client != sender { if err := client.WriteMessage(websocket.TextMessage, message); err != nil { - s.logger.Error("Failed to write message to client", zap.Error(err)) + s.logger.Debug("Failed to write message to client", zap.Error(err)) } } }