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

Connection timeout for attempting to connect to MQTT server? #94

Open
shinglaifs opened this issue Feb 26, 2022 · 4 comments
Open

Connection timeout for attempting to connect to MQTT server? #94

shinglaifs opened this issue Feb 26, 2022 · 4 comments

Comments

@shinglaifs
Copy link

Is there currently a way to set the connection timeout for attempting to connect to the MQTT server?
I realize that the current coding the mqttclient.connect() will take about 20 seconds before giving up on the attempting to connect to an IP that simply cannot be reach in the network.

@hirotakaster
Copy link
Owner

Hi @shinglaifs ,
This library base network IO is TCPClient , this TCPClient class don't have a network timeout option. And tcp timeout option is depend on particle firmware board&stack, If you want to set a timeout option you'll need to build custom firmware.

@shinglaifs
Copy link
Author

@hirotakaster thank you very much for your prompt response.
Right, I probably don't have the skill set to do a custom firmware.

However, I try to see if there is any other method that will work.
I come across the AsyncTCPclient example:
https://github.com/rickkas7/asynctcpclient/blob/master/AsyncTCPClient.cpp
from their threading tutortial: https://community.particle.io/t/particle-threads-tutorial/41362
Do you think this method (using threading and mutex) will work for the mqttclient.connect() ?

@hirotakaster
Copy link
Owner

@shinglaifs Yes, AsyncTCPClient maybe work well, but I don't test with it and it difficult to check the problem as his comment 'Most APIs are not thread safe'. Because of that I think a lot of modification will be needed with AsyncTCPClient.
But I think 'Why server side IP endpoint not work?' is based MQTT server side HA(High Avaliabilty), so I think emqtt or mosquitto-cluster is good HA MQTT server for don't stop the endpoint IP address.

@shinglaifs
Copy link
Author

thank you @hirotakaster , I will give AsyncTCPClient method a try with your library.
And if it works, i will share it back here.

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

2 participants