当前位置:网站首页>QtMqtt 源码编译设置KeepAlive后ping包超时错误不返回问题修复(QMQTT::MqttNoPingResponse,QMQTT::ClientPrivate::onPingTimeo)
QtMqtt 源码编译设置KeepAlive后ping包超时错误不返回问题修复(QMQTT::MqttNoPingResponse,QMQTT::ClientPrivate::onPingTimeo)
2022-06-10 17:38:00 【_Hello Spring】
调用 setKeepAlive() 设置心跳包后,心跳可以正常收发

此时断开网络出现如下情况

明显出现还未超时就重启了超时定时器,查看源码如下:
void QMQTT::ClientPrivate::onTimerPingReq()
{
if (!isConnectedToHost())
return;
Frame frame(PINGREQ);
sendFrame(frame);
_pingResponseTimer.start(); // 直接就重启了定时器永远不会超时
}
在启动超时定时器时判断定时器是否活动,处于非活动状态才能启动,修改代码如下:
void QMQTT::ClientPrivate::onTimerPingReq()
{
if (!isConnectedToHost())
return;
Frame frame(PINGREQ);
sendFrame(frame);
if(!_pingResponseTimer.isActive()) {
_pingResponseTimer.start();
}
}
修改完后编译测试可正常超时断连。

边栏推荐
- 如何定位游戏发热问题
- CodeCraft-22 and Codeforces Round #795 (Div. 2)
- ZigBee模块无线传输星形拓扑组网结构简介
- Abbexa 1,3-二棕榈素 CLIA 试剂盒解决方案
- High number_ Chapter 6 infinite series__ Absolute convergence_ Conditional convergence
- Jouer avec la classe de fonctions de pytorch
- c语言---8 初识常见关键字
- 图像搜索是什么
- The relationship between trees, forests and binary trees
- Red vertical left side menu navigation code
猜你喜欢

AOV network topology sorting

Talk about those things about telecommuting, participate in the essay solicitation, receive the contribution fee and win the grand prize!

Abbexa 1,3-二棕榈素 CLIA 试剂盒解决方案

LeetCode树经典题目(一)

红色垂直左侧边菜单导航代码

c语言---4 初识常量

c语言---11 分支语句if else

优惠券的工厂与策略模式实现方案

mmdetection之model构建

Noise line h5js effect realized by canvas
随机推荐
LeetCode 255. Verifying preorder traversal sequence binary search tree*
踩坑了,BigDecimal 使用不当,造成P0事故!
AOE网关键路径
CUDA realizes efficient search - failed audit?
.NET 开源的免费午餐结束了?
Library for adding progress bar during training --tqdm
QTableWidget / QTableView实用技巧
Some views on the current CIM (bim+gis) industry
CCF A类会议或期刊----回归相关论文
c语言---3 初识变量
YML file configuration parameter definition dictionary and list
High number_ Chapter 6 infinite series__ Properties of positive series
我在做一件很酷的事情
Solve the problem that vs2022 slowly loads a pile of symbols when debugging the program
Adding rendererdata of URP with script
Abbkine柱式法ExKine Pro动物细胞/组织总蛋白提取试剂盒
字符串的分析和使用 上
Canvas fire burning H5 animation JS special effects
Talk about those things about telecommuting, participate in the essay solicitation, receive the contribution fee and win the grand prize!
c语言---12 分支语句switch