Sets a 20 second MQTT keepalive intervall

This commit is contained in:
Nadja Reitzenstein 2022-02-15 17:43:50 +01:00
parent 2777645205
commit 337e8aa563

View File

@ -3,6 +3,7 @@ use std::task::{Poll, Context};
use std::sync::Mutex; use std::sync::Mutex;
use std::collections::HashMap; use std::collections::HashMap;
use std::future::Future; use std::future::Future;
use std::time::Duration;
use futures::{future::BoxFuture, Stream}; use futures::{future::BoxFuture, Stream};
use futures::channel::mpsc; use futures::channel::mpsc;
@ -142,7 +143,11 @@ pub fn load(log: &Logger, config: &Config) -> Result<(ActorMap, Vec<Actor>)> {
let tok = c.reconnect(); let tok = c.reconnect();
smol::block_on(tok); smol::block_on(tok);
}); });
let tok = mqtt.connect(paho_mqtt::ConnectOptions::new()); let conn_opts = paho_mqtt::ConnectOptionsBuilder::new()
.keep_alive_interval(Duration::from_secs(20))
.clean_session(false)
.finalize();
let tok = mqtt.connect(conn_opts);
smol::block_on(tok)?; smol::block_on(tok)?;
let actuators = config.actors.iter() let actuators = config.actors.iter()