persistence of the mosquitoes in the wild

To publish at QOS 2 is a multi step process so the most likely reason is that you are disconnecting the publishing client before all the messages are actually finishing publishing to the broker. You should probably do that publishing in a loop and using the returned token from the call to client.publish() to wait until it has completed before disconnecting the client.

e.g. as shown in the example:

//Publish 5 messages to /go-mqtt/sample at qos 1 and wait for the receipt
//from the server after sending each message
for i := 0; i < 5; i++ {
  text := fmt.Sprintf("this is msg #%d!", i)
  token := c.Publish("go-mqtt/sample", 0, false, text)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top