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)