diff --git a/provider/mqtt/client.go b/provider/mqtt/client.go index 2f03ec80a..cd2f930cd 100644 --- a/provider/mqtt/client.go +++ b/provider/mqtt/client.go @@ -123,7 +123,7 @@ func (m *Client) ConnectionHandler(client paho.Client) { // Cleanup recursively removes a topic func (m *Client) Cleanup(topic string, retained bool) error { - if m.Client.Subscribe(topic, m.Qos, func(c paho.Client, msg paho.Message) { + if !m.Client.Subscribe(topic, m.Qos, func(c paho.Client, msg paho.Message) { if len(msg.Payload()) == 0 { return } @@ -136,7 +136,7 @@ func (m *Client) Cleanup(topic string, retained bool) error { time.Sleep(time.Second) - if m.Client.Unsubscribe(topic).WaitTimeout(request.Timeout) { + if !m.Client.Unsubscribe(topic).WaitTimeout(request.Timeout) { return api.ErrTimeout } diff --git a/server/mqtt.go b/server/mqtt.go index 25681cfbc..a302374a5 100644 --- a/server/mqtt.go +++ b/server/mqtt.go @@ -37,6 +37,9 @@ func NewMQTT(root string, site site.API) (*MQTT, error) { if err == nil { err = m.Listen(site) } + if err != nil { + err = fmt.Errorf("mqtt: %w", err) + } return m, err }