当前位置:网站首页>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();
}
}
修改完后编译测试可正常超时断连。

边栏推荐
- c语言---5 初识字符串、转义字符、注释
- 你还在手写TS类型代码吗
- 字符串的分析和使用 上
- Memory pool principle I (based on the whole block)
- Some views on the current CIM (bim+gis) industry
- (CVPR 2020) RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds
- 仅需三步学会使用低代码ThingJS与森数据DIX数据对接
- C语言---1 C语言认知
- Generate XML based on annotations and reflection
- Canvas大火燃烧h5动画js特效
猜你喜欢

Summary of all contents of cloud computing setup to ensure that a complete cloud computing server can be built, including node installation, instance allocation, network configuration, etc

mmdetection之model构建

Abbexa 无细胞 DNA 试剂盒说明书

搭建在线帮助中心,轻松帮助客户解决问题

mmdetection之dataloader构建

c语言---7 初识操作符

Canvas大火燃烧h5动画js特效

Abbexa CDAN1 siRNA使用说明书

c语言---3 初识变量

True thesis of information system project manager in the first half of 2022
随机推荐
Numpy - record
[technical analysis] discuss the production process and technology of big world games - preliminary process
js模糊阴影跟随动画js特效插件
LeetCode 321. 拼接最大數***
用脚本添加URP的RendererData
Play with pytoch's function class
Some views on the current CIM (bim+gis) industry
堆利用之chunk extend: HITCON tranining lab13
Wireshark learning notes (I) common function cases and skills
盛最多水得容器
CUDA Programming (I): add two arrays
Red vertical left side menu navigation code
c语言---11 分支语句if else
项目中常用的19条MySQL优化
Unity stepping on the pit record: if you inherit monobehavior, the constructor of the class may be called multiple times by unity. Do not initialize the constructor
【FAQ】运动健康服务REST API接口使用过程中常见问题和解决方法总结
pwnable start
c语言---6 初识选择语句、循环语句、函数以及数组
c语言---12 分支语句switch
Aesthetic experience (episode 237) Luo Guozheng