From 7de7a8ddaa965e55c91656e4cd955a24bd02941c Mon Sep 17 00:00:00 2001 From: Jan Koppe Date: Mon, 16 Dec 2024 17:04:00 +0100 Subject: [PATCH] correct warn level identifier, disable mqtt autoreconnects warning level must be identified with 'warn' string to be formatted by viri. with the autoreconnecting things enabled, the mqtt library will try to infinitely reconnect without showing the underlying issue. for now, let's rather fail hard on the face and spit out the issue on the console. better connection handling is still required, not sure how it behaves when the mqtt connection breaks during runtime. --- main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index dca8194..ae2372b 100644 --- a/main.go +++ b/main.go @@ -227,7 +227,7 @@ func wingLoop(wing *WingClient, MQTTClient mqtt.Client, MQTTTopic *string) { if !wingCheckResult.IsOK { sendAlert := false var msgs []string - level := "warning" + level := "warn" for _, reason := range wingCheckResult.NotOKReasons { // First let's build the message(s) we want to send. We might have multiple reasons. // Even if the reason we're iterating on right now should not be sent out yet, we should @@ -295,10 +295,10 @@ func newMQTTClient(broker *string, username *string, password *string, clientID opts := mqtt.NewClientOptions() opts.SetTLSConfig(&tlsConfig) opts.AddBroker(*broker) - opts.SetConnectRetry(true) - opts.SetAutoReconnect(true) - opts.SetConnectRetryInterval(1 * time.Second) - opts.SetConnectTimeout(5 * time.Second) + //opts.SetConnectRetry(true) + //opts.SetAutoReconnect(true) + //opts.SetConnectRetryInterval(1 * time.Second) + opts.SetConnectTimeout(2 * time.Second) opts.SetClientID(*clientID) if *username != "" { opts.SetUsername(*username)