This commit is contained in:
laodaming 2023-07-26 18:32:39 +08:00
parent 857a632cea
commit 636bc0aee7

View File

@ -148,6 +148,8 @@ func (w *wsConnectItem) heartbeat() {
case <-w.closeChan: case <-w.closeChan:
return return
case <-tick: case <-tick:
//设置写超时时间10s
_ = w.conn.SetWriteDeadline(time.Now().Add(time.Second * 10))
//发送心跳信息 //发送心跳信息
if err := w.conn.WriteMessage(websocket.PongMessage, nil); err != nil { if err := w.conn.WriteMessage(websocket.PongMessage, nil); err != nil {
logx.Error("发送心跳信息异常,关闭连接:", w.flag, err) logx.Error("发送心跳信息异常,关闭连接:", w.flag, err)