Hi,
I need a way to know the MQTT connection status at any time, so that I can reconnect to the MQTT broker again.
I observe that the call back function registered via "qapi_Net_MQTTc_Register_Connect_Callback()" does not get called for every disconnect to the MQTT broker.
Also the function qapi_Net_MQTTc_Publish() returns success, even after the MQTT disconnects. Also qapi_Status_t returned by function qapi_Net_MQTTc_Publish() is "QAPI_NET_STATUS_MQTTC_CONNECT_SUCCEEDED" after the MQTT disconnects.
After MQTT disconnect may be 10-20 minutes later, the API qapi_Net_MQTTc_Publish() returns error "QAPI_NET_STATUS_MQTTC_SOCKET_WRITE_ERROR".
I will require MQTT connection status immediately not after 10 -15 minutes. Is there any way I can get the MQTT connection status immediatley.
Thanks in advance.
Regards,
Jagan
Hi,
I think, I will require to implement PINGREQ and PINGRESP to check if the connection is alive. More details are below.
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/errata01/os/mqtt-v3.1.1-errata01-os-complete.html#_Toc442180894
Please let me know how to implement with the given set of QAPIs.
Regards,
Jagan
mqtt_connect() internally uses PINGREQ and PINGRESP.
However, for you test case, kindly configure the keepalive_sec and ConAck_wait_time intervals to valid value to verify the connection status at regular intervals.
Thanks raja.
After configuring keepalive_sec and ConAck_wait_time, I am able to see PINGREQ in the server logs. Also MQTT connection seems to be stable. I am testing more, I will let you know if I face any issues.