From: Jonathan McDowell Date: Wed, 31 Jul 2024 08:22:09 +0000 (+0100) Subject: Add automatic MQTT reconnection X-Git-Tag: v0.2.0~11 X-Git-Url: https://the.earth.li/gitweb/?a=commitdiff_plain;h=f140a1cc41a446f9717881de0ce516c5ab44539d;p=mqttdeck.git Add automatic MQTT reconnection If the MQTT server goes away we want to try and reconnect automatically. --- diff --git a/src/main.rs b/src/main.rs index 89fc007..ad2abc2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ use elgato_streamdeck::{list_devices, new_hidapi, AsyncStreamDeck, StreamDeckInp use ini::Ini; use paho_mqtt as mqtt; use std::process; +use std::time::Duration; #[derive(Parser)] struct Args { @@ -77,6 +78,7 @@ async fn main() { .user_name(&conf["MQTT"]["username"]) .password(&conf["MQTT"]["password"]) .will_message(lwt_msg) + .automatic_reconnect(Duration::new(2,0), Duration::new(60,0)) .finalize(); if let Err(err) = cli.connect(conn_opts).wait() {