mirror of
https://github.com/safing/portbase
synced 2025-09-04 03:29:59 +00:00
Detect close errors
This commit is contained in:
parent
fe7b09c9fb
commit
37189b07cf
1 changed files with 16 additions and 4 deletions
|
@ -127,8 +127,14 @@ func (api *DatabaseAPI) handler() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !api.shuttingDown.IsSet() {
|
if !api.shuttingDown.IsSet() {
|
||||||
api.shutdown()
|
api.shutdown()
|
||||||
if !websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseGoingAway) {
|
if websocket.IsCloseError(err,
|
||||||
log.Warningf("api: websocket write error: %s", err)
|
websocket.CloseNormalClosure,
|
||||||
|
websocket.CloseGoingAway,
|
||||||
|
websocket.CloseAbnormalClosure,
|
||||||
|
) {
|
||||||
|
log.Infof("api: websocket connection to %s closed", api.conn.RemoteAddr())
|
||||||
|
} else {
|
||||||
|
log.Warningf("api: websocket read error from %s: %s", api.conn.RemoteAddr(), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -204,8 +210,14 @@ func (api *DatabaseAPI) writer() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !api.shuttingDown.IsSet() {
|
if !api.shuttingDown.IsSet() {
|
||||||
api.shutdown()
|
api.shutdown()
|
||||||
if !websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseGoingAway) {
|
if websocket.IsCloseError(err,
|
||||||
log.Warningf("api: websocket write error: %s", err)
|
websocket.CloseNormalClosure,
|
||||||
|
websocket.CloseGoingAway,
|
||||||
|
websocket.CloseAbnormalClosure,
|
||||||
|
) {
|
||||||
|
log.Infof("api: websocket connection to %s closed", api.conn.RemoteAddr())
|
||||||
|
} else {
|
||||||
|
log.Warningf("api: websocket write error to %s: %s", api.conn.RemoteAddr(), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Reference in a new issue