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

边栏推荐
- AOE network critical path
- .NET 开源的免费午餐结束了?
- Numpy - record
- LeetCode 321. 拼接最大數***
- 小程序积分商城如何实现营销目的
- Linear mobile chess
- C language -- 13 loop statement while
- 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之dataset类解读
- Leetcode 875. Coco, who likes bananas
猜你喜欢

【技术分析】探讨大世界游戏的制作流程及技术——前期流程篇

Chunk extend: hit training lab13

High number_ Chapter 6 infinite series__ Absolute convergence_ Conditional convergence

Wireshark learning notes (I) common function cases and skills

Postman-接口测试工具

(CVPR 2020) RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds

C language -- 13 loop statement while

Cdga| six key points of data governance for industrial enterprises

AOE network critical path

LeetCode树经典题目(一)
随机推荐
我在做一件很酷的事情
Canvas fire burning H5 animation JS special effects
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
yml文件配置参数定义字典和列表
Summary of vim common commands
玩转Pytorch的Function类
True thesis of information system project manager in the first half of 2022
领导提拔你的原因,只有这点最真实,其他都是瞎扯!
The relationship between trees, forests and binary trees
LoRa模块无线收发通信技术详解
[technical analysis] discuss the production process and technology of big world games - preliminary process
微信小程序仿陶票票课程设计
[FAQ] summary of common problems and solutions during the use of rest API interface of sports health service
LeetCode 321. Maximum number of splices***
Wireshark learning notes (I) common function cases and skills
电商行业转账返款方案分析
掌握高性能计算前,我们先了解一下它的历史
Swin_Transformer源码解读
安装Linux系统的MySQL,在xshell中遇见的问题
分享我做Dotnet9博客网站时积累的一些资料