{"id":23806,"date":"2019-05-11T17:38:41","date_gmt":"2019-05-12T00:38:41","guid":{"rendered":"https:\/\/m2msupport.net\/m2msupport\/?page_id=23806"},"modified":"2019-06-02T12:08:04","modified_gmt":"2019-06-02T19:08:04","slug":"mqtt-keep-alive-pingreq-pingresp","status":"publish","type":"page","link":"https:\/\/m2msupport.net\/m2msupport\/mqtt-keep-alive-pingreq-pingresp\/","title":{"rendered":"MQTT Keep Alive &#8211; PINGREQ &#038; PINGRESP"},"content":{"rendered":"<p>MQTT Keep Alive feature ensures that the connection between the MQTT client and MQTT broker is still open and both the parties of aware of the&nbsp; connection status.<\/p>\n<h3><strong>Related Topics<\/strong><\/h3>\n<ul>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/how-mqtt-works\/\">How MQTT works?<\/a><\/li>\n<li>MQTT \u2013 Connect to Broker\n<ul>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-connect-to-eclipse-public-mqtt-server\/\">Connect to Eclipse public MQTT Server<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-connect-to-mosquitto-broker-on-local-windows-machine\/\">Connect to Mosquitto MQTT server on local Windows machine<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-topics\/\">MQTT Topics<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-publish\/\">MQTT Publish<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-subscriber\/\">MQTT Subscribe<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-quality-of-service-qos\/\">MQTT Quality of Service (QoS)<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-keep-alive-pingreq-pingresp\/\">MQTT &#8211; Keep Alive with PINGREQ and PINGRESP<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/install-mqtt-broker-mosquitto-in-windows\/\">Install MQTT broker Mosquitto in Windows<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-user-authentication\/\">Mosquitto Broker \u2013 Enable user authentication<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-user-name-and-password-authentication-to-mqtt-broker-connection\/\">MQTT Broker connection with user name and password<\/a><\/li>\n<\/ul>\n<p>When the MQTT client is not sending any message, it needs to send the PINGREQ message before the keep-alive interval expires. MQTT broker will respond with the PINGRESP message in one and half times the keep alive interval.<\/p>\n<p><a href=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_keep_alive.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-23808\" src=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_keep_alive.png\" alt=\"\" width=\"1258\" height=\"740\" srcset=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_keep_alive.png 1258w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_keep_alive-300x176.png 300w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_keep_alive-768x452.png 768w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_keep_alive-1024x602.png 1024w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_keep_alive-600x353.png 600w\" sizes=\"auto, (max-width: 1258px) 100vw, 1258px\" \/><\/a><\/p>\n<h3><strong>MQTT Server Log for Keep Alive<\/strong><\/h3>\n<p>In the below log, MQTT client send the PINGREQ message to the MQTT broker every keep alive interval after the PUBLISH messages are sent. MQTT broker will acknowledge with the PINGRESP response.<\/p>\n<p>1557618075: Received PUBLISH from 2481 (d0, q2, r0, m14, &#8216;SensorReadings&#8217;, &#8230; (19 bytes))<br \/>\n1557618075: Sending PUBREC to 2481 (m14, rc0)<br \/>\n1557618075: Received PUBREL from 2481 (Mid: 14)<br \/>\n1557618075: Sending PUBCOMP to 2481 (m14)<br \/>\n1557618135: Received PINGREQ from 2481<br \/>\n1557618135: Sending PINGRESP to 2481<br \/>\n1557618195: Received PINGREQ from 2481<br \/>\n1557618195: Sending PINGRESP to 2481<\/p>\n<div class=\"video-responsive\"><iframe loading=\"lazy\" id=\"youTubePlayer\" src=\"https:\/\/www.youtube.com\/embed\/2aLAgxi6Pq8\" width=\"750\" height=\"421\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\n","protected":false},"excerpt":{"rendered":"<p>MQTT Keep Alive feature ensures that the connection between the MQTT client and MQTT broker is still open and both the parties of aware of the&nbsp; connection status. Related Topics How MQTT works? MQTT \u2013 Connect to Broker Connect to &hellip; <a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-keep-alive-pingreq-pingresp\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"software_howto.php","meta":{"footnotes":""},"class_list":["post-23806","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages\/23806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/comments?post=23806"}],"version-history":[{"count":4,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages\/23806\/revisions"}],"predecessor-version":[{"id":26663,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages\/23806\/revisions\/26663"}],"wp:attachment":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/media?parent=23806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}