Skip to content

Commit

Permalink
fix: correctly handle normal ws closure
Browse files Browse the repository at this point in the history
  • Loading branch information
jpts committed Jun 22, 2023
1 parent 31451d7 commit 806d623
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ func (d *WebsocketRoundTripper) WsCallback(ws *websocket.Conn) error {
}()

for err := range errChan {
if e, ok := err.(*websocket.CloseError); ok {
klog.V(4).Infof("Closing websocket connection with error code %d, err: %s", e.Code, err)
}
if websocket.IsCloseError(err, websocket.CloseNormalClosure) {
return nil
} else if errors.Is(err, io.EOF) {
klog.V(4).Info("Closing websocket connection with EOF")
return nil
}
if e, ok := err.(*websocket.CloseError); ok {
klog.V(4).Infof("Closing websocket connection with error code %d, err: %s", e.Code, err)
}
return err
}
return nil
Expand Down

0 comments on commit 806d623

Please sign in to comment.