diff options
| -rw-r--r-- | mqtt.go | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -29,6 +29,7 @@ func MQTTRun(tx chan MQTTMessage) { opts.SetClientID(CLIENT_ID) opts.SetCleanSession(true) opts.SetOnConnectHandler(MQTTOnConnectHandler) + opts.SetConnectionLostHandler(MQTTConnectionLostHandler) client := mqtt.NewClient(opts) @@ -49,3 +50,7 @@ func MQTTRun(tx chan MQTTMessage) { func MQTTOnConnectHandler(c mqtt.Client) { log.Printf("Connected to MQTT broker (%s)", BROKER) } + +func MQTTConnectionLostHandler(c mqtt.Client, err error) { + log.Printf("Connection to MQTT broker lost: %v", err) +} |
