-
Notifications
You must be signed in to change notification settings - Fork 14
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
Reconnect to MQTT broker if connection is dropped #98
Conversation
We also need to set clean_session to false, so we don't lose our previous subscriptions.
homie-influx/src/main.rs
Outdated
} | ||
|
||
simplify_unit_vec(try_join_all(join_handles).await) | ||
simplify_unit_vec(try_join_all(join_handles).await)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to simplify it you are throwing the result away
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sensible. Hopefully it fixes your dad's problem.
|
||
const DEFAULT_MQTT_CLIENT_PREFIX: &str = "homie-influx"; | ||
const DEFAULT_MQTT_HOST: &str = "test.mosquitto.org"; | ||
const DEFAULT_MQTT_PORT: u16 = 1883; | ||
const DEFAULT_MQTT_RECONNECT_INTERVAL: Duration = Duration::from_secs(5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How long does it take to get synced up with all the mqtt state? If you were in a fresh loop, what fraction of your time would be spent hammering the server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The state is preserved on the broker when clean_session
is set to false, so the client just needs to authenticate and connect/conack. WIthout a delay it just seems to constantly try to reconnect. I didn't check CPU usage, but there was certainly a lot of log spam.
This should fix the
homie-influx
part of #7. It also makes errors writing to InfluxDB non-fatal. There is no point crashing just because one database isn't working, as the others may still work.