Skip to content

Commit

Permalink
Websocket: ignore upgrade errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Sep 1, 2024
1 parent 8ac3b3c commit 1b3a5b1
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions server/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package server

import (
"context"
"errors"
"net/http"
"strings"
"sync"
Expand Down Expand Up @@ -65,17 +64,8 @@ func (h *SocketHub) ServeWebsocket(w http.ResponseWriter, r *http.Request) {
}
defer conn.Close(websocket.StatusInternalError, "")

err = h.subscribe(r.Context(), conn)

if errors.Is(err, context.Canceled) {
return
}
if cs := websocket.CloseStatus(err); cs == websocket.StatusNormalClosure || cs == websocket.StatusGoingAway {
return
}
if err != nil {
log.ERROR.Println(err)
return
if err := h.subscribe(r.Context(), conn); err != nil {
log.TRACE.Println("web socket upgrade:", err)
}
}

Expand Down

0 comments on commit 1b3a5b1

Please sign in to comment.