mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-22 06:47:56 +01:00
Make MQTT client try to reconnect on connection lost or disconnect
This commit is contained in:
parent
7019f2d065
commit
0d2f0a49da
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -504,7 +504,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "diflouroborane"
|
name = "diflouroborane"
|
||||||
version = "0.2.1"
|
version = "0.2.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-channel",
|
"async-channel",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
2
schema
2
schema
@ -1 +1 @@
|
|||||||
Subproject commit c855646a90958ae575d58be074d187acb9f8f4fa
|
Subproject commit 18ed9c2ae6a221f57d19e255165c7ebc4508e9af
|
14
src/actor.rs
14
src/actor.rs
@ -129,7 +129,19 @@ impl Actuator for Dummy {
|
|||||||
pub fn load(log: &Logger, config: &Config) -> Result<(ActorMap, Vec<Actor>)> {
|
pub fn load(log: &Logger, config: &Config) -> Result<(ActorMap, Vec<Actor>)> {
|
||||||
let mut map = HashMap::new();
|
let mut map = HashMap::new();
|
||||||
|
|
||||||
let mqtt = AsyncClient::new(config.mqtt_url.clone())?;
|
let mut mqtt = AsyncClient::new(config.mqtt_url.clone())?;
|
||||||
|
let dlog = log.clone();
|
||||||
|
mqtt.set_disconnected_callback(move |c, prop, reason| {
|
||||||
|
error!(dlog, "got Disconnect({}) message from MQTT Broker: {:?}", reason, prop);
|
||||||
|
let tok = c.reconnect();
|
||||||
|
smol::block_on(tok);
|
||||||
|
});
|
||||||
|
let dlog = log.clone();
|
||||||
|
mqtt.set_connection_lost_callback(move |c| {
|
||||||
|
error!(dlog, "lost connection to MQTT Broker!");
|
||||||
|
let tok = c.reconnect();
|
||||||
|
smol::block_on(tok);
|
||||||
|
});
|
||||||
let tok = mqtt.connect(paho_mqtt::ConnectOptions::new());
|
let tok = mqtt.connect(paho_mqtt::ConnectOptions::new());
|
||||||
smol::block_on(tok)?;
|
smol::block_on(tok)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user