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

MQTT: reconnect after broken connection? #52

Open
flipsa opened this issue May 15, 2019 · 0 comments
Open

MQTT: reconnect after broken connection? #52

flipsa opened this issue May 15, 2019 · 0 comments

Comments

@flipsa
Copy link

flipsa commented May 15, 2019

Hey TVE,

Thanks for esp-link and el-client, your work is much appreciated!

I've been using esp-link (v3.2.47-g9c6530d) succesfully for an Arduino (Mega) project I'm working on and just added MQTT support through el-client (v3.0.alpha0) to publish status and sensor data, which then gets picked up by an mqtt broker running in a Openhab (home automation) instance to display nice graphs from the sensor data.

The problem I'm facing is identical or similar to #8: sometimes the MQTT connection between the el-client and the Openhab instance goes down, usually only for seconds or sometimes in the range of a few minutes. In the serial log I can see that the mqttDisconnect callback is being called a few times (usually twice or three times within a short time like a minute or so) but then the callback is not being called again afterwards, or at least I don't see any "MQTT disconnected" messages on the serial monitor.

If the connection to Openhab is re-established before that, then it resumes publishing status data. However, if the issue persists a bit longer (a few minutes), the mqtt connection is never re-established from the Arduino's side of things, BUT, the esp-link MQTT status info (rssi and heap) will reconnect just fine and I can receive the status data in Openhab without any issues.

How can I make sure that the Arduino also notices that the connection is working again and then start publishing the mqtt data again? I tried manually calling the esp.Sync(); function in the MQTT disconnect callback, but that reliably crashes the Arduino.

Any help is appreciated...

Edit: Added version information for esp-link and el-client.

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

No branches or pull requests

1 participant