Skip to content

Commit

Permalink
fix: unncessary logging of messages
Browse files Browse the repository at this point in the history
  • Loading branch information
elskow committed Oct 21, 2024
1 parent 00bb6f4 commit 51b54e8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions videochat-cp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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))
}
}
}
Expand Down

0 comments on commit 51b54e8

Please sign in to comment.