mirror of https://github.com/gorilla/websocket.git
Do not handle network error in SetCloseHandler()
The 666c197
added an error handling in `SetCloseHandler()` and peer
stops getting `CloseError` when network issue like `write: broken
pipe` happens because the close handle returns the error.
Hence this patch changes to skip network error handling.
This commit is contained in:
parent
0f0acefeac
commit
9a2140519a
6
conn.go
6
conn.go
|
@ -1159,9 +1159,13 @@ func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
|
||||||
h = func(code int, text string) error {
|
h = func(code int, text string) error {
|
||||||
message := FormatCloseMessage(code, "")
|
message := FormatCloseMessage(code, "")
|
||||||
err := c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
|
err := c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
|
||||||
if err != nil && err != ErrCloseSent {
|
if err != nil {
|
||||||
|
if _, ok := err.(net.Error); ok {
|
||||||
|
return nil
|
||||||
|
} else if err != ErrCloseSent {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue