From 7f76d5bc8e1a1d5c0660437d2cb0c513e0dd2b39 Mon Sep 17 00:00:00 2001 From: Kaby Chow Date: Fri, 20 Dec 2024 21:57:50 +0800 Subject: [PATCH] Don't log 1006 error https://github.com/gorilla/websocket/blob/b65e62901fc1c0d968042419e74789f6af455eb9/examples/chat/client.go#L65-L71 --- socket/framesocket.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/socket/framesocket.go b/socket/framesocket.go index 148c7008..319594a5 100644 --- a/socket/framesocket.go +++ b/socket/framesocket.go @@ -223,7 +223,9 @@ func (fs *FrameSocket) readPump(conn *websocket.Conn, ctx context.Context) { if err != nil { // Ignore the error if the context has been closed if !errors.Is(ctx.Err(), context.Canceled) { - fs.log.Errorf("Error reading from websocket: %v", err) + if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) { + fs.log.Errorf("Error reading from websocket: %v", err) + } } return } else if msgType != websocket.BinaryMessage {