Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-1103 - Fixing broken pipe errors #1170

Merged
merged 3 commits into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions internal/server/websocketServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Reques

// closing handshake
defer func() {
_ = conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (normal)"))
closeErr := conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (normal)"))
if closeErr != nil {
slog.Debug("Error during closing handshake", slog.Any("error", closeErr))
}
conn.Close()
}()

Expand All @@ -131,9 +134,10 @@ func (s *WebsocketServer) WebsocketHandler(w http.ResponseWriter, r *http.Reques
if err != nil {
// acceptable close errors
errs := []int{websocket.CloseNormalClosure, websocket.CloseGoingAway, websocket.CloseAbnormalClosure}
if !websocket.IsCloseError(err, errs...) {
slog.Warn("failed to read message from client", slog.Any("error", err))
if websocket.IsCloseError(err, errs...) {
break
}
slog.Error("Error reading message", slog.Any("error", err))
break
}

Expand Down