Even more resiliency

This commit is contained in:
2022-10-16 21:27:48 +01:00
parent 146980f5da
commit 6a328de5d5

View File

@@ -186,7 +186,9 @@ fn mqtt_connect(uri: String, client_id: String) -> Result<mqtt::Client, mqtt::Er
.finalize();
// Create a client.
let mqtt_client = mqtt::Client::new(mqtt_opts)?;
let mut mqtt_client = mqtt::Client::new(mqtt_opts)?;
mqtt_client.set_timeout(Duration::from_secs(5));
// Define the set of options for the connection.
let mqtt_conn_opts = mqtt::ConnectOptionsBuilder::new()
@@ -248,7 +250,7 @@ fn main() {
// TODO: Publish Home Assistant autodiscovery message (retained)
loop {
while mqtt_client.is_connected() {
match gather(&solax_url, &flags.solax_password) {
Ok(msg) => {
if let Some(e) = publish(&mqtt_client, msg, mqtt_qos) {