mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
enhance: handle websocket error
This commit is contained in:
parent
7a9aa3a33b
commit
ff1399e044
8 changed files with 126 additions and 60 deletions
|
@ -2,6 +2,7 @@ package analytic
|
|||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/analytic"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
|
@ -27,10 +28,7 @@ func GetNodeStat(c *gin.Context) {
|
|||
for {
|
||||
// write
|
||||
err = ws.WriteJSON(analytic.GetNodeStat())
|
||||
if err != nil || websocket.IsUnexpectedCloseError(err,
|
||||
websocket.CloseGoingAway,
|
||||
websocket.CloseNoStatusReceived,
|
||||
websocket.CloseNormalClosure) {
|
||||
if helper.IsUnexpectedWebsocketError(err) {
|
||||
logger.Error(err)
|
||||
break
|
||||
}
|
||||
|
@ -57,10 +55,7 @@ func GetNodesAnalytic(c *gin.Context) {
|
|||
for {
|
||||
// write
|
||||
err = ws.WriteJSON(analytic.NodeMap)
|
||||
if err != nil || websocket.IsUnexpectedCloseError(err,
|
||||
websocket.CloseGoingAway,
|
||||
websocket.CloseNoStatusReceived,
|
||||
websocket.CloseNormalClosure) {
|
||||
if helper.IsUnexpectedWebsocketError(err) {
|
||||
logger.Error(err)
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue