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

Add mqtt reconnect on idle #10

Closed
pontostroy opened this issue Jul 15, 2024 · 3 comments · Fixed by #11
Closed

Add mqtt reconnect on idle #10

pontostroy opened this issue Jul 15, 2024 · 3 comments · Fixed by #11

Comments

@pontostroy
Copy link

Please add this feature as in python exporter, reconnect if empty queue after using mobile app.

@tess1o
Copy link
Owner

tess1o commented Jul 15, 2024

I will check the issue in this exporter and if MQTT behaves in the same way I'll implement the reconnection after not recieiving messages for XXX seconds.

@tess1o
Copy link
Owner

tess1o commented Jul 15, 2024

Yes, the issue can be reproduced on IOS and MQTT exporter (exporter via REST API works fine).

I'll prepare a fix. There are two options:

  1. Unsubscribe from the topic (where we receive messages from the devices) and then subscribe again. I need to test if it helps.
  2. Disconnect from the broker and connect again.

I'd prefer the first option if it works.

@tess1o
Copy link
Owner

tess1o commented Jul 15, 2024

Implemented in version 1.2.1 - https://github.com/tess1o/go-ecoflow-exporter/releases/tag/1.2.1

The logic is the following:
Check if we don't receive messages from MQTT for all devices within threshold (env variable MQTT_DEVICE_OFFLINE_THRESHOLD_SECONDS, default value 60 seconds). If true, disconnect from broker and connect again.

Note: If one device receives messages and another device doesn't receive messages, it means that the second device is just offline and there is no need to reconnect. In this case we set all metrics to 0.

Thank you for pointing to this critical issue.

@tess1o tess1o closed this as completed Jul 15, 2024
@tess1o tess1o linked a pull request Jul 15, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants