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.
This commit is contained in:
Jan Koppe 2024-12-16 17:04:00 +01:00
parent 044c33334b
commit 7de7a8ddaa
Signed by: thunfisch
GPG Key ID: BE935B0735A2129B
1 changed files with 5 additions and 5 deletions

10
main.go
View File

@ -227,7 +227,7 @@ func wingLoop(wing *WingClient, MQTTClient mqtt.Client, MQTTTopic *string) {
if !wingCheckResult.IsOK { if !wingCheckResult.IsOK {
sendAlert := false sendAlert := false
var msgs []string var msgs []string
level := "warning" level := "warn"
for _, reason := range wingCheckResult.NotOKReasons { for _, reason := range wingCheckResult.NotOKReasons {
// First let's build the message(s) we want to send. We might have multiple reasons. // 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 // 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 := mqtt.NewClientOptions()
opts.SetTLSConfig(&tlsConfig) opts.SetTLSConfig(&tlsConfig)
opts.AddBroker(*broker) opts.AddBroker(*broker)
opts.SetConnectRetry(true) //opts.SetConnectRetry(true)
opts.SetAutoReconnect(true) //opts.SetAutoReconnect(true)
opts.SetConnectRetryInterval(1 * time.Second) //opts.SetConnectRetryInterval(1 * time.Second)
opts.SetConnectTimeout(5 * time.Second) opts.SetConnectTimeout(2 * time.Second)
opts.SetClientID(*clientID) opts.SetClientID(*clientID)
if *username != "" { if *username != "" {
opts.SetUsername(*username) opts.SetUsername(*username)