LiamBindle / MQTT-C

A portable MQTT C client for embedded systems and PCs alike.
https://liambindle.ca/MQTT-C
MIT License
766 stars 269 forks source link

how to check network connection state in inspector callback #173

Open applea9 opened 1 year ago

applea9 commented 1 year ago

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.

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!