nginx-ui/internal/helper/websocket_error.go
Jacky cb4977e5ab
refactor: nodes analytics (#847)
* refactor: nodes analytics

* feat(debug): add pprof in debug mode

* refactor: websocket error handler
2025-02-05 18:19:17 +08:00

25 lines
609 B
Go

package helper
import (
"errors"
"github.com/gorilla/websocket"
"strings"
"syscall"
)
// IsUnexpectedWebsocketError checks if the error is an unexpected websocket error
func IsUnexpectedWebsocketError(err error) bool {
// ignore: write: broken pipe
if errors.Is(err, syscall.EPIPE) {
return false
}
// client closed error: *net.OpErr
if strings.Contains(err.Error(), "An existing connection was forcibly closed by the remote host") {
return false
}
return websocket.IsUnexpectedCloseError(err,
websocket.CloseGoingAway,
websocket.CloseNoStatusReceived,
websocket.CloseNormalClosure)
}