From 636bc0aee715f8d2f6cd072a90495e059007bac0 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 26 Jul 2023 18:32:39 +0800 Subject: [PATCH] fix --- server/websocket/internal/logic/datatransferlogic.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 49e81fe0..c8270928 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -148,6 +148,8 @@ func (w *wsConnectItem) heartbeat() { case <-w.closeChan: return case <-tick: + //设置写超时时间10s + _ = w.conn.SetWriteDeadline(time.Now().Add(time.Second * 10)) //发送心跳信息 if err := w.conn.WriteMessage(websocket.PongMessage, nil); err != nil { logx.Error("发送心跳信息异常,关闭连接:", w.flag, err)