This commit is contained in:
laodaming 2023-10-20 14:12:29 +08:00
parent c523a5a7c6
commit 4c50131761

View File

@ -322,10 +322,14 @@ func (w *wsConnectItem) heartbeat() {
w.debug = nil
}
//发送心跳信息
if err := w.conn.WriteMessage(websocket.PongMessage, w.respondDataFormat(constants.WEBSOCKET_HEARTBEAT, websocket_data.HeartBeatMsg{
WsCount: currentWebsocketConnectCount,
CombineCount: currentRequestCombineApiCount,
})); err != nil {
var d interface{}
if w.debug != nil {
d = websocket_data.HeartBeatMsg{
WsCount: currentWebsocketConnectCount,
CombineCount: currentRequestCombineApiCount,
}
}
if err := w.conn.WriteMessage(websocket.PongMessage, w.respondDataFormat(constants.WEBSOCKET_HEARTBEAT, d)); err != nil {
logx.Error("发送心跳信息异常,关闭连接:", w.uniqueId, err)
w.close()
return