-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
First run mqttclient.loop() takes 15+ seconds #308
Comments
I have found that changing two lines in PubSubClient.h has varying effects as follows... Next I tried with KEEPALIVE 10, and SOCKET_TIMEOUT 5. I then tried with KEEPALIVE 10, and SOCKET_TIMEOUT 15. So it seems for some reason the socket is timing out. But what does this mean? After the timeout it is connected and I can publish and subscribe and they work. But the sensor might reconnect again once or 20 times each day. This is really bugging me. |
Anyone? |
gjt211 Please try fix, at let met know if works you you |
Hi, I'm using your library with the TASMOTO project here on github to work with the SONOFF devices. I can confirm, that the first .loop() take forever ~20 seconds. I just downloaded the version today Master branch and recompile everything. I do not see a change or better behavior. I will look into the change. Maybe I have an idea. I can confirm that after the first hang everything is working fine. |
OK. after manual moving the change to my codebase it works. |
I am using this library with a WiFi secure connection to my own dedicated server running Mosquitto.
After Wi-Fi is connected and secure connection made to my server, In my main loop, I test if mqtt is connected.
if (!mqttclient.connected()) { reconnect(); }
Then in my reconnect function (which is really both a connect & reconnect function), I have the following code
When this code is run, the
mqttclient.loop();
it takes around 15 seconds to complete.Previously this function did NOT have the mqttclient.loop() and was relying on the mqttclient.loop() inside the main program loop. I added it here as it was also taking 15 seconds in the main loop the first time the loop ran. As the mqttclient.loop() is blocking, at least performing the first call after an mqttclient.connect I have a little better control over it.
It is typically between 15100mS - 15800mS, however sometimes I have seen it as high as 40000mS.
Any ideas why this takes 15+ seconds?
The text was updated successfully, but these errors were encountered: