diff --git a/cmd/dashboard/controller/common_page.go b/cmd/dashboard/controller/common_page.go index 57a4bae..5a97624 100644 --- a/cmd/dashboard/controller/common_page.go +++ b/cmd/dashboard/controller/common_page.go @@ -185,6 +185,7 @@ func (cp *commonPage) ws(c *gin.Context) { return } defer conn.Close() + count := 0 for { dao.SortedServerLock.RLock() err = conn.WriteJSON(dao.SortedServerList) @@ -192,6 +193,10 @@ func (cp *commonPage) ws(c *gin.Context) { if err != nil { break } + count += 1 + if count%4 == 0 { + conn.WriteMessage(websocket.PingMessage, []byte{}) + } time.Sleep(time.Second * 2) } }