Browse Source

fix(node_record): handle unexpected websocket errors gracefully in nodeAnalyticRecord function

Jacky 1 day ago
parent
commit
cd464b55b2
1 changed files with 5 additions and 1 deletions
  1. 5 1
      internal/analytic/node_record.go

+ 5 - 1
internal/analytic/node_record.go

@@ -6,6 +6,7 @@ import (
 	"sync"
 	"time"
 
+	"github.com/0xJacky/Nginx-UI/internal/helper"
 	"github.com/0xJacky/Nginx-UI/model"
 	"github.com/0xJacky/Nginx-UI/query"
 	"github.com/gorilla/websocket"
@@ -209,7 +210,10 @@ func nodeAnalyticRecord(env *model.Environment, ctx context.Context) error {
 	for {
 		err = c.ReadJSON(&nodeStat)
 		if err != nil {
-			return err
+			if helper.IsUnexpectedWebsocketError(err) {
+				return err
+			}
+			return nil
 		}
 
 		// set online