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:
parent
58abbcc02c
commit
ec0fd4f916
1 changed files with 3 additions and 0 deletions
3
main.go
3
main.go
|
@ -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),
|
||||||
|
|
Loading…
Reference in a new issue