diff --git a/main.go b/main.go index 09854b9..ef99375 100644 --- a/main.go +++ b/main.go @@ -105,6 +105,9 @@ func animator(tk *rgbmatrix.ToolKit, mqMessages chan mqtt.Message) { tk.PlayAnimation(NewAnimation(image.Point{64, 32}, mqMessages)) } +func onConnectionLostHandler(c MQTT.Client, reason error) { + log.Fatalf(reason.Error()) +} func setupMQTT() *mqtt.ClientOptions { opts := MQTT.NewClientOptions() opts.AddBroker(fmt.Sprintf("tcp://%s:%s", os.Getenv("MQTTBROKER"), os.Getenv("MQTTPORT"))) @@ -112,6 +115,7 @@ func setupMQTT() *mqtt.ClientOptions { opts.SetPassword(os.Getenv("MQTTPASSWORD")) opts.SetClientID("rgbboard") opts.SetAutoReconnect(true) + opts.SetConnectionLostHandler(onConnectionLostHandler) return opts }