1
0
Fork 0
mirror of https://github.com/Luzifer/mqttcli.git synced 2024-11-09 15:20:06 +00:00

Set connection lost handler to exit subscription mode

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2022-02-07 15:54:36 +01:00
parent 58abbcc02c
commit ec0fd4f916
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -68,6 +68,9 @@ func main() {
mqtt.NewClientOptions(). mqtt.NewClientOptions().
AddBroker(cfg.MQTTBroker). AddBroker(cfg.MQTTBroker).
SetClientID(cfg.MQTTClientID). SetClientID(cfg.MQTTClientID).
SetConnectionLostHandler(func(_ mqtt.Client, err error) {
log.WithError(err).Fatal("Connection to broker lost")
}).
SetKeepAlive(cfg.MQTTTimeout). SetKeepAlive(cfg.MQTTTimeout).
SetPassword(cfg.MQTTPass). SetPassword(cfg.MQTTPass).
SetUsername(cfg.MQTTUser), SetUsername(cfg.MQTTUser),