Skip to content

Commit 3fdf2f0

Browse files
committed
wsutil: Added graceful close checking
1 parent 169cf7d commit 3fdf2f0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

utils/wsutil/conn.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"io"
88
"net/http"
9+
"strings"
910
"time"
1011

1112
"github.com/gorilla/websocket"
@@ -167,6 +168,12 @@ func startReadLoop(conn *websocket.Conn, eventCh chan<- Event) {
167168
return
168169
}
169170

171+
// Is the error an intentional close call? Go 1.16 exposes
172+
// ErrClosing, but we have to do this for now.
173+
if strings.HasSuffix(err.Error(), "use of closed network connection") {
174+
return
175+
}
176+
170177
// Check if the error is a normal one:
171178
if websocket.IsCloseError(err, websocket.CloseNormalClosure) {
172179
return

0 commit comments

Comments
 (0)