Skip to content

Commit 39f9fc4

Browse files
author
Johan Brandhorst
authored
Gracefully handle websocket CloseNormalClosure
These used to trigger a nasty warning message, now they just log to the debug logger instead.
1 parent c631b53 commit 39f9fc4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

wsproxy/websocket_proxy.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ func websocketProxy(w http.ResponseWriter, r *http.Request, h http.Handler) {
108108
log.Debugln("[read] reading from socket.")
109109
_, p, err := conn.ReadMessage()
110110
if err != nil {
111+
if cErr, ok := err.(*websocket.CloseError); ok && cErr.Code == websocket.CloseNormalClosure {
112+
log.Debugln("[read] websocket closed successfully")
113+
return
114+
}
115+
111116
log.Warnln("error reading websocket message:", err)
112117
return
113118
}

0 commit comments

Comments
 (0)