From f140a1cc41a446f9717881de0ce516c5ab44539d Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Wed, 31 Jul 2024 09:22:09 +0100 Subject: [PATCH] Add automatic MQTT reconnection If the MQTT server goes away we want to try and reconnect automatically. --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) 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() { -- 2.39.5