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:
parent
044c33334b
commit
7de7a8ddaa
10
main.go
10
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)
|
||||
|
|
Loading…
Reference in New Issue