chore(controller): show alert on broker disconnection

This commit is contained in:
Leandro Antônio Farias Machado 2023-06-16 00:12:54 -03:00
parent a0fef6c36e
commit 57ebbc7c45

View File

@ -140,6 +140,12 @@ func (m *Mqtt) startClient(devices, controller, disconnect, apiMsg chan *paho.Pu
clientConfig := paho.ClientConfig{
Conn: conn,
Router: singleHandler,
OnServerDisconnect: func(disconnect *paho.Disconnect) {
log.Println("disconnected from mqtt server, reason code: ", disconnect.ReasonCode)
},
OnClientError: func(err error) {
log.Println(err)
},
}
return paho.NewClient(clientConfig)