Skip to content

Commit

Permalink
Trying to diagnose memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
h00s committed Jan 21, 2024
1 parent 269b71a commit ffca496
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions mqtt/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ func NewMQTT(c *config.MQTT) *MQTT {
}

func (m *MQTT) Publish(topic string, message string) {
go func() {
if m.client.IsConnected() {
if token := m.client.Publish(topic, 0, false, message); token.Error() != nil {
log.Println(token.Error())
}
log.Println("Published to MQTT topic: ", topic)
if m.client.IsConnected() {
if token := m.client.Publish(topic, 0, false, message); token.Error() != nil {
log.Println(token.Error())
}
}()
log.Println("Published to MQTT topic: ", topic)
}
}

func (m *MQTT) Close() {
Expand Down

0 comments on commit ffca496

Please sign in to comment.