If connection is lost to the mqtt server, attempt to reconnect instead of panicking
This commit is contained in:
parent
06389d83f7
commit
d55540a6c0
|
@ -1,6 +1,6 @@
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use tracing::{error, debug};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
use rumqttc::{Publish, Event, Incoming, EventLoop};
|
use rumqttc::{Publish, Event, Incoming, EventLoop};
|
||||||
use tokio::sync::broadcast;
|
use tokio::sync::broadcast;
|
||||||
|
@ -39,13 +39,12 @@ impl Mqtt {
|
||||||
},
|
},
|
||||||
Ok(..) => continue,
|
Ok(..) => continue,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("{}", err);
|
// Something has gone wrong
|
||||||
break
|
// We stay in the loop as that will attempt to reconnect
|
||||||
|
warn!("{}", err);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
todo!("Error in MQTT (most likely lost connection to mqtt server), we need to handle these errors!");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user