summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2025-12-20 13:32:55 +0100
committerxengineering <me@xengineering.eu>2025-12-20 13:32:55 +0100
commit12198f4d921eb6406d08a122e2e51971bf65e7fa (patch)
tree22cfd487fedfc54a364686a1540c9475d0c738e6
parent96299467958aaffdbef5cb8ae780d3abeddfcaba (diff)
downloadsia-server-12198f4d921eb6406d08a122e2e51971bf65e7fa.tar
sia-server-12198f4d921eb6406d08a122e2e51971bf65e7fa.tar.zst
sia-server-12198f4d921eb6406d08a122e2e51971bf65e7fa.zip
Log MQTT disconnect
This makes connection loss visible during debugging.
-rw-r--r--mqtt.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/mqtt.go b/mqtt.go
index 2fd4d13..1f935cf 100644
--- a/mqtt.go
+++ b/mqtt.go
@@ -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)
+}