The keepalive feature in MQTT helps detecting connection problems. That is, if the broker has not received any data from the client in 1.5 * keepalive
seconds, it considers the client disconnected. But who should send periodic pings when keepalive is enabled? Broker or client?
The MQTT standard at http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349238 states that the client must send PINGREQ packets if it has no other data to send.
On another hand, mosquitto_connect()
function of libmosquitto (https://mosquitto.org/api/files/mosquitto-h.html#mosquitto_connect) has the following description of keepalive
parameter:
keepalive: the number of seconds after which the broker should send a PING message to the client if no other messages have been exchanged in that time.
I wanted to clear up this confusion. I lean towards the variant from MQTT standard, but would like to know for sure. Also maybe this indicates a bug in libmosquitto implementation?
Specifically, I use libmosquitto version 1.6.12.