mirror of
https://github.com/Luzifer/mqttcli.git
synced 2024-11-08 14:50:11 +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().
|
||||
AddBroker(cfg.MQTTBroker).
|
||||
SetClientID(cfg.MQTTClientID).
|
||||
SetConnectionLostHandler(func(_ mqtt.Client, err error) {
|
||||
log.WithError(err).Fatal("Connection to broker lost")
|
||||
}).
|
||||
SetKeepAlive(cfg.MQTTTimeout).
|
||||
SetPassword(cfg.MQTTPass).
|
||||
SetUsername(cfg.MQTTUser),
|
||||
|
|
Loading…
Reference in a new issue