I met some problems when using MQTT-C library to communicate with MQTT broker.
When the network connection is broken, mqtt_sync() will use nearly 16 minutes to detect the network connection broken and change the error to MQTT_ERROR_SOCKET_ERROR.
In the first 9 minutes, mqtt_sync() calls __mqtt_recv() and __mqtt_send() without any problem though the network connection is broken.
And in the following 7 minutes, mqtt_sync() is blocked in _mqtt_send() and continuously calls the mqtt_pal_sendall() which causes the CPU load quite high.
Afterwards, the error changes to MQTT_ERROR_SOCKET_ERROR.
I have two questions:
1) why does mqtt_sync() need so long time to detect the network connection and change the error state?
2) If I want to check network connection in the inspector callback, is there any example? I have tried to use getsockopt to check socket state, but it does not work.
Hi,
I met some problems when using MQTT-C library to communicate with MQTT broker.
When the network connection is broken, mqtt_sync() will use nearly 16 minutes to detect the network connection broken and change the error to MQTT_ERROR_SOCKET_ERROR.
In the first 9 minutes, mqtt_sync() calls __mqtt_recv() and __mqtt_send() without any problem though the network connection is broken.
And in the following 7 minutes, mqtt_sync() is blocked in _mqtt_send() and continuously calls the mqtt_pal_sendall() which causes the CPU load quite high.
Afterwards, the error changes to MQTT_ERROR_SOCKET_ERROR.
I have two questions:
1) why does mqtt_sync() need so long time to detect the network connection and change the error state?
2) If I want to check network connection in the inspector callback, is there any example? I have tried to use getsockopt to check socket state, but it does not work.
Thanks for your reply!