diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index c8270928..2250611e 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -142,7 +142,7 @@ func (l *DataTransferLogic) checkAuth(svcCtx *svc.ServiceContext, r *http.Reques // 心跳 func (w *wsConnectItem) heartbeat() { - tick := time.Tick(time.Second * 10) + tick := time.Tick(time.Second * 2) for { select { case <-w.closeChan: @@ -166,6 +166,7 @@ func (w *wsConnectItem) close() { defer w.mutex.Unlock() logx.Info("websocket:", w.flag, " is closing...") //发送关闭信息 + _ = w.conn.SetWriteDeadline(time.Now().Add(time.Second)) _ = w.conn.WriteMessage(websocket.CloseMessage, nil) w.conn.Close() mapConnPool.Delete(w.flag)