From f609fa364dc5b95477c681af9a2b8ebea85ebb65 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 26 Jul 2023 19:19:20 +0800 Subject: [PATCH] fix --- server/websocket/internal/logic/datatransferlogic.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)