retry MQTT connections, even if initial connection attempt fails
This commit is contained in:
parent
32b0dc7d59
commit
c3c531931c
@ -30,6 +30,7 @@ func publisherLoop(requests <-chan PublishRequest) error {
|
||||
log.Printf("Connecting to MQTT broker %q (configured in %s)", broker, configFn)
|
||||
opts := mqtt.NewClientOptions().AddBroker(broker)
|
||||
opts.SetClientID("dhcp4d")
|
||||
opts.SetConnectRetry(true)
|
||||
mqttClient := mqtt.NewClient(opts)
|
||||
if token := mqttClient.Connect(); token.Wait() && token.Error() != nil {
|
||||
return fmt.Errorf("MQTT connection failed: %v", token.Error())
|
||||
|
Loading…
x
Reference in New Issue
Block a user