You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Publish works fine except for honoring the retain flag. Broker works fine with external publishing with retain.
Using master branch: 460f0ef
package main
import (
"fmt""os""os/signal""syscall""time"
mqtt "github.com/mochi-co/mqtt/server""github.com/mochi-co/mqtt/server/listeners""github.com/mochi-co/mqtt/server/listeners/auth"
)
funcmain() {
sigs:=make(chan os.Signal, 1)
done:=make(chanbool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
gofunc() {
<-sigsdone<-true
}()
server:=mqtt.New()
tcp:=listeners.NewTCP("t1", ":1883")
server.AddListener(tcp, &listeners.Config{Auth: new(auth.Allow)})
// server.Serve doesn't block, so no need for goroutine, but for some// reason, we have to delay a LONG time for Serve's goroutines to start-up// > 1 second on a 5900X !!server.Serve()
fmt.Println("\nServer is running")
fmt.Println("Sleeping for 2 seconds")
time.Sleep(2*time.Second)
// Publish with retain - doesn't workserver.Publish("direct/publish", []byte("Published from broker"), true)
fmt.Println("\nMessage published to \"direct/publish\" with retain")
fmt.Println("\nTry running: mosquitto_sub -v -t \"direct/publish\"")
<-done
}
go run main.go
# In another terminal window# The following shows nothing
mosquitto_sub -v -t "direct/publish"# But this works:
mosquitto_pub -t "mosquitto/publish" -m "from mosquitto_pub" -r
mosquitto_sub -v -t "mosquitto/publish"
Am I missing something?
The text was updated successfully, but these errors were encountered:
bldrdash
changed the title
Publish with retain doesn't work
Publish with retain doesn't retain
Mar 14, 2022
Error logic is as follows:
trie.go: RetainMessage method always return 0 if len(msg.payload) > 0
server.go:retainMessage method updates topic's retain message when q=1,and deletes stored retain message if q is not equal to 1.
Publish works fine except for honoring the retain flag. Broker works fine with external publishing with retain.
Using master branch: 460f0ef
Am I missing something?
The text was updated successfully, but these errors were encountered: