Skip to content

Commit

Permalink
fix(analytic):client closed error in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
caisi35 committed Jan 22, 2025
1 parent 5911462 commit 94e69f1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/analytic/analytic.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/uozi-tech/cosy/logger"
"net/http"
"runtime"
"strings"
"time"

"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -86,7 +87,12 @@ func Analytic(c *gin.Context) {

// write
err = ws.WriteJSON(stat)
if helper.IsUnexpectedWebsocketError(err) {
// client closed error: *net.OpErr
var closedErr bool
if err != nil {
closedErr = strings.Contains(err.Error(), "An existing connection was forcibly closed by the remote host")
}
if helper.IsUnexpectedWebsocketError(err) || closedErr {
logger.Error(err)
break
}
Expand Down

0 comments on commit 94e69f1

Please sign in to comment.