fix(analytic):client closed error in windows

This commit is contained in:
caisi35 2025-01-22 15:37:59 +08:00
parent 5911462f90
commit d73ee1f035

View file

@ -1,6 +1,7 @@
package helper package helper
import ( import (
"strings"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/pkg/errors" "github.com/pkg/errors"
"syscall" "syscall"
@ -15,6 +16,11 @@ func IsUnexpectedWebsocketError(err error) bool {
if errors.Is(err, syscall.EPIPE) { if errors.Is(err, syscall.EPIPE) {
return false return false
} }
// client closed error: *net.OpErr
if strings.Contains(err.Error(), "An existing connection was forcibly closed by the remote host") {
return true
}
return websocket.IsUnexpectedCloseError(err, return websocket.IsUnexpectedCloseError(err,
websocket.CloseGoingAway, websocket.CloseGoingAway,
websocket.CloseNoStatusReceived, websocket.CloseNoStatusReceived,