Try to be a bit more resilient mqtt-side
This commit is contained in:
@@ -182,6 +182,7 @@ fn mqtt_connect(uri: String, client_id: String) -> Result<mqtt::Client, mqtt::Er
|
||||
let mqtt_opts = mqtt::CreateOptionsBuilder::new()
|
||||
.server_uri(uri)
|
||||
.client_id(client_id)
|
||||
.send_while_disconnected(false)
|
||||
.finalize();
|
||||
|
||||
// Create a client.
|
||||
@@ -189,7 +190,7 @@ fn mqtt_connect(uri: String, client_id: String) -> Result<mqtt::Client, mqtt::Er
|
||||
|
||||
// Define the set of options for the connection.
|
||||
let mqtt_conn_opts = mqtt::ConnectOptionsBuilder::new()
|
||||
.keep_alive_interval(Duration::from_secs(20))
|
||||
.keep_alive_interval(Duration::from_secs(5))
|
||||
.clean_session(true)
|
||||
.finalize();
|
||||
|
||||
@@ -245,6 +246,8 @@ fn main() {
|
||||
|
||||
let mqtt_client = mqtt_connect(flags.mqtt_url, mqtt_client_id).unwrap();
|
||||
|
||||
// TODO: Publish Home Assistant autodiscovery message (retained)
|
||||
|
||||
loop {
|
||||
match gather(&solax_url, &flags.solax_password) {
|
||||
Ok(msg) => {
|
||||
|
Reference in New Issue
Block a user