Skip to content

Commit c17b7ce

Browse files
committed
MQTT: fix missing birth message on reconnect
1 parent a486ef5 commit c17b7ce

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

buses/mqtt/mqtt.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func (mqtt *Bus) Initialize(config config.MqttConfig) {
3131

3232
mqttOpts.OnConnect = func(client MQTT.Client) {
3333
fmt.Printf("MQTT: CONNECTED TO %s\n", config.Server)
34+
mqtt.SendMessage(config.TopicRoot+"/alarmserver", `{ "status": "up" }`)
3435
}
3536

3637
mqttOpts.SetConnectionLostHandler(func(client MQTT.Client, err error) {
@@ -50,8 +51,6 @@ func (mqtt *Bus) Initialize(config config.MqttConfig) {
5051
if token := mqtt.client.Connect(); token.Wait() && token.Error() != nil {
5152
panic(token.Error())
5253
}
53-
54-
mqtt.SendMessage(config.TopicRoot+"/alarmserver", `{ "status": "up" }`)
5554
}
5655

5756
func (mqtt *Bus) SendMessage(topic string, payload interface{}) {

0 commit comments

Comments
 (0)