-
Notifications
You must be signed in to change notification settings - Fork 423
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
MQTT Does not reconnect #149
Labels
Comments
Thank you for sharing your findings. |
omersiar
added a commit
that referenced
this issue
Sep 3, 2018
@omersiar I adopted your changes for setting the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested with 0.8.0 , but looking at the 0.8.1 code I think it will be the same.
When the mqtt server is down or for whatever reason the mqtt connection is lost, there will be a line in the eventlog:
Disconnected from MQTT server | TCP_DISCONNECTED
but reconnect never works.I added some debug writes to the eventlog to see where it fails, but I can't find the issue. After discovering the disconnect a reconnect is scheduled for after 60 seconds. The attempt is made, but the connect is never arrived at the mqtt server, resulting in a loop to try to reconnect.
Looking at some issues of the used AsyncMqttClient lib, I'm feeling the issue might be in the lib?
To summarize:
UPDATE : After a tonload of testing, debugging and pulling my hair out, I managed to have a reconnect!
In the
onMqttDisconnect
function I added setting (again) the server to connect to, right before calling the ticker:mqttClient.setServer("192.168.2.6", 1883);
It seems that somehow magically the library forgets it's server connection (but remembers the user / pass).
Easiest solution would be the re-read the json and set the server from the config, or on booting up push the server settings in global variables and use it in the onMqttDisconnect.
For now I have a quick dirty ptach by simply hardcoding the broker address.
The text was updated successfully, but these errors were encountered: