enhance: handle websocket error

This commit is contained in:
Jacky 2024-07-20 18:35:06 +08:00
parent 7a9aa3a33b
commit ff1399e044
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
8 changed files with 126 additions and 60 deletions

View file

@ -3,6 +3,7 @@ package analytic
import (
"fmt"
"github.com/0xJacky/Nginx-UI/internal/analytic"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/host"
@ -75,10 +76,7 @@ func Analytic(c *gin.Context) {
// write
err = ws.WriteJSON(stat)
if err != nil || websocket.IsUnexpectedCloseError(err,
websocket.CloseGoingAway,
websocket.CloseNoStatusReceived,
websocket.CloseNormalClosure) {
if helper.IsUnexpectedWebsocketError(err) {
logger.Error(err)
break
}