mqttdpms: Enable automatic reconnect
Some checks reported errors
dustin/mqttdpms/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
dustin/mqttdpms/pipeline/head Something is wrong with the build of this commit
Apparently, *paho-mqtt* does not enable automatic reconnect by default.
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use paho_mqtt as mqtt;
|
use paho_mqtt as mqtt;
|
||||||
@@ -83,6 +85,10 @@ impl MqttDpms {
|
|||||||
let mut client = mqtt::AsyncClient::new(client_opts)?;
|
let mut client = mqtt::AsyncClient::new(client_opts)?;
|
||||||
let mut conn_opts = mqtt::ConnectOptionsBuilder::new();
|
let mut conn_opts = mqtt::ConnectOptionsBuilder::new();
|
||||||
conn_opts.will_message(self.will_message());
|
conn_opts.will_message(self.will_message());
|
||||||
|
conn_opts.automatic_reconnect(
|
||||||
|
Duration::from_millis(500),
|
||||||
|
Duration::from_secs(30),
|
||||||
|
);
|
||||||
if self.config.mqtt.tls {
|
if self.config.mqtt.tls {
|
||||||
let ssl_opts = mqtt::SslOptionsBuilder::new()
|
let ssl_opts = mqtt::SslOptionsBuilder::new()
|
||||||
.trust_store(&self.config.mqtt.ca_file)?
|
.trust_store(&self.config.mqtt.ca_file)?
|
||||||
|
|||||||
Reference in New Issue
Block a user