-
Notifications
You must be signed in to change notification settings - Fork 558
Closed
Description
Subscribing to /a/#
works correctly.
However, if one subscribes to /a/b/#
and unsubscribes from it afterwards, the earlier message handler doesn't receive anything anymore, although the broker publishes according to tcpdump
.
To reproduce:
package main
import (
"log"
"time"
mqtt "github.com/eclipse/paho.mqtt.golang"
)
func msgHandler(_ mqtt.Client, m mqtt.Message) {
log.Printf("received message for topic %s: %s", m.Topic(), string(m.Payload()))
}
func main() {
o := mqtt.NewClientOptions().AddBroker("tcp://" + "iot.eclipse.org:1883")
c := mqtt.NewClient(o)
if t := c.Connect(); t.Wait() && t.Error() != nil {
panic(t.Error())
}
if t := c.Subscribe("/a/#", 1, msgHandler); t.Wait() && t.Error() != nil {
panic(t.Error())
}
if t := c.Subscribe("/a/b/#", 1, msgHandler); t.Wait() && t.Error() != nil {
panic(t.Error())
}
if t := c.Unsubscribe("/a/b/#"); t.Wait() && t.Error() != nil {
panic(t.Error())
}
time.Sleep(time.Hour)
}
And publish messages from the console with:
mosquitto_pub -h iot.eclipse.org -t '/a/b/hello' -d -m 'xxxx' -q 1
mosquitto_pub -h iot.eclipse.org -t '/a/hello' -d -m 'xxxx' -q 1
My expectation is to receive those messages. In practice, nothing happens.
To verify that the example isn't broken itself, remove the last Subscribe
and Unsubscribe
.
Metadata
Metadata
Assignees
Labels
No labels