QoS2 Broker resend Publish question

Trying to test my code using mosquitto 2.0.15.

I am testing out a client subscribed to a single topic, QoS2. I can successfully receive a topic, send the REC, get the REL and send the COMP. No problem.

However, when I purposely do not send the REC, I do not see a retransmit from the broker.

What am I missing here?

Thanks,
Paul

Hello,

The broker will not attempt to resend a PUBLISH message if you do not send a PUBACK/PUBREC, assuming that the connection does not end.

MQTT uses TCP, which is a reliable transport which will ensure that all data makes from the sender to the receiver unless there is a break in the connection. It is not possible for data to go missing part way through a connection if that connection remains.

This means that there is no point trying to resend a PUBLISH if the connection has not dropped. Your client has received the PUBLISH correctly, it has just chosen not to send an acknowledgement. This may be because the client needs to do a lot of processing on the message before it makes the acknowledgement, in this case sending a new copy of the PUBLISH would not be helpful. Alternatively, the client may want to reply very quickly, but is otherwise overloaded and so is unable to do so - sending a new PUBLISH would cause further load for the client that will not help. Finally, the connection may have actually dropped and the client not received the PUBLISH, but it is not apparent to the broker that the connection has dropped. In this case, sending a new PUBLISH will not help either. When the connection drops and the client reconnects, the broker will send any unacknowledged messages again, assuming the client is connecting with clean start = false.

I hope this makes things clearer.

Roger

The broker is simply waiting for your PUBREC response. As long as your network connection is existing there is not need for the broker to resend the messages. Even more as long as the client is sending PINGREQ messages periodically.
If you disconnect and reconnect the client you should receive resend of the message. Important side note: You have to use a fixed clientid and clean session needs to be false.
Another comment: The Mosquitto broker has an limit on the number of messages being in-flight to the client (default 20). After sending out 20 different messages and NOT recevieing a PUBREC, the broker will stop sending any QOS 1/2 messages until the acknowledge cycle for a previous message is finished.

Thanks for the responses.
Roger, I have definitely seen the “cause further load” portion of this situation. We have timeouts where we attempt to resend a PUB if no response has been received. As the system load gets higher (> 10k / s), we might trigger a retransmit. This quickly degrades and we end up disconnecting, so I am in favor of no retransmits.
Norbert, yes in my testing I set the broker in-flight queue size to 1 and dropped a PUBREC. This prevented the broker from processing any further messages from the client until I sent the PUBREC or reconnected.
This info definitely helps with my client development. Thanks again!

1 Like