diff --git a/cmd/calls/main.go b/cmd/calls/main.go index 30ea231..b2bd07c 100644 --- a/cmd/calls/main.go +++ b/cmd/calls/main.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "errors" "flag" "log" "net/http" @@ -90,8 +91,11 @@ func main() { defer close(done) for { t, message, err := c.ReadMessage() + closeErr := &websocket.CloseError{} if err != nil { - log.Println("read:", err) + if !(errors.As(err, &closeErr) && closeErr.Code == 1000) { // normal closure + log.Println("read:", err) + } return } @@ -127,7 +131,7 @@ func main() { case <-done: return case <-interrupt: - log.Println("interrupt") + log.Println() // Cleanly close the connection by sending a close message and then // waiting (with timeout) for the server to close the connection. diff --git a/pkg/gordio/nexus/websocket.go b/pkg/gordio/nexus/websocket.go index 22fb391..aa490d4 100644 --- a/pkg/gordio/nexus/websocket.go +++ b/pkg/gordio/nexus/websocket.go @@ -110,7 +110,7 @@ func (conn *wsConn) readPump(ctx context.Context, reg Registry, c Client) { for { _, message, err := conn.ReadMessage() if err != nil { - if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) { + if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure, websocket.CloseNormalClosure) { log.Debug().Err(err).Str("conn", conn.RemoteAddr().String()).Msg("unexpected close") return }