Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to check network connection state in inspector callback #173

Open
applea9 opened this issue Oct 27, 2022 · 0 comments
Open

how to check network connection state in inspector callback #173

applea9 opened this issue Oct 27, 2022 · 0 comments

Comments

@applea9
Copy link

applea9 commented Oct 27, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant