Skip to content

Commit

Permalink
made changes to log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Kannav02 committed Oct 24, 2024
1 parent f806080 commit 0bdb5fe
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions internal/server/websocketServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,25 @@ func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Reques
defer func() {
closeErr := conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (normal)"))
if closeErr != nil {
slog.Warn("Error during closing handshake", slog.Any("error", closeErr))
slog.Debug("Error during closing handshake", slog.Any("error", closeErr))
}
conn.Close()
}()

maxRetries := config.DiceConfig.WebSocket.MaxWriteResponseRetries
for {
// read incoming message
messageType, msg, err := conn.ReadMessage()
_, msg, err := conn.ReadMessage()
if err != nil {
// acceptable close errors
errs := []int{websocket.CloseNormalClosure, websocket.CloseGoingAway, websocket.CloseAbnormalClosure}
if websocket.IsCloseError(err, errs...) {
slog.Info("Gracefully Exited")
break
}
slog.Error("Error reading message", slog.Any("error", err))
break
}

if messageType == websocket.CloseMessage {
slog.Info("graceful shutdown...")
break
}

// parse message to dice command
diceDBCmd, err := utils.ParseWebsocketMessage(msg)
if errors.Is(err, diceerrors.ErrEmptyCommand) {
Expand Down

0 comments on commit 0bdb5fe

Please sign in to comment.