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

Reconnect to MQTT broker if connection is dropped #98

Merged
merged 5 commits into from
Dec 17, 2020
Merged

Conversation

qwandor
Copy link
Collaborator

@qwandor qwandor commented Dec 16, 2020

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.

}

simplify_unit_vec(try_join_all(join_handles).await)
simplify_unit_vec(try_join_all(join_handles).await)?;
Copy link
Owner

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Owner

@alsuren alsuren left a 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);
Copy link
Owner

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?

Copy link
Collaborator Author

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.

@qwandor qwandor merged commit 800da5c into master Dec 17, 2020
@qwandor qwandor deleted the hi-error branch December 17, 2020 19:20
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 this pull request may close these issues.

None yet

2 participants