Add AutoReconnect setting for MQTT client.
All checks were successful
Build Docker image / build (push) Successful in 4m46s

This commit is contained in:
Pieter Hollander 2024-02-17 16:54:24 +01:00
parent 8132344c2a
commit 5be69f9baf
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg

View file

@ -1,3 +1,4 @@
// TODO: Optimisation: only log dt1, dt2, rt1, rt2, g on change.
package main package main
import ( import (
@ -65,6 +66,7 @@ func main() {
opts.AddBroker(os.Getenv("MQTT_BROKER")) opts.AddBroker(os.Getenv("MQTT_BROKER"))
opts.SetUsername(os.Getenv("MQTT_USERNAME")) opts.SetUsername(os.Getenv("MQTT_USERNAME"))
opts.SetPassword(os.Getenv("MQTT_PASSWORD")) opts.SetPassword(os.Getenv("MQTT_PASSWORD"))
opts.SetAutoReconnect(true)
// Connect to MQTT broker // Connect to MQTT broker
client := mqtt.NewClient(opts) client := mqtt.NewClient(opts)