paho mqtt的keepAliveInterval

一、keepAliveInterval

所用的版本为1.3.12

实验一、

这个值设置的30,打开mqtt的trace,发现每隔33s发送一次pingreq

paho mqtt的keepAliveInterval_第1张图片

note:

期间,client和server一直保持qos0的消息交互(client->server)

实验二、

这个值设置的30,30s间隔内发布qos 1消息

paho mqtt的keepAliveInterval_第2张图片

paho mqtt的keepAliveInterval_第3张图片

二、keep alive时间超时导致的掉线

paho mqtt的keepAliveInterval_第4张图片paho mqtt的keepAliveInterval_第5张图片

三、源码分析 

https://github.com/eclipse/paho.mqtt.c/blob/1b431761e41236b3159876a314061f3e2ec27254/src/MQTTProtocolClient.c#L700C22-L700C22

ref:

paho mqtt c 源码分析-2 (心跳机制) - 简书

emqx通知客户端离线的时间比较理论值长 - EMQX - EMQ 问答社区

MQTT Keep Alive Interval Explained With Examples

Keep Alive is not sent properly · Issue #1284 · eclipse/paho.mqtt.c · GitHub 

MQTT client mistakenly doesn't send PINGREQs if it has received messages from the broker · Issue #1277 · eclipse/paho.mqtt.c · GitHub

mqtt keepalive / emq x broker 验证 client不发心跳后,server最大等待间隔_emqx keepalive_ogre2020的博客-CSDN博客

MQTT 协议 Keep Alive 详解 | EMQ 

你可能感兴趣的:(MQTT,mqtt)