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

@ -1,6 +1,7 @@
package upstream
import (
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/upstream"
"github.com/gin-gonic/gin"
@ -35,11 +36,7 @@ func AvailabilityTest(c *gin.Context) {
for {
err = ws.WriteJSON(upstream.AvailabilityTest(body))
if err != nil || websocket.IsUnexpectedCloseError(err,
websocket.CloseGoingAway,
websocket.CloseNoStatusReceived,
websocket.CloseNormalClosure) {
if helper.IsUnexpectedWebsocketError(err) {
logger.Error(err)
break
}