Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the meaning of QoS2 in MQTT

In MQTT I have still problems to understand QoS2.
The 4-way handshake is:

  1. message is sent from a sender to the receiver
  2. Receiver answers with PUBREC
  3. Sender answers with PUBLREL
  4. Receiver answers with PUBCOMP

But what happens, when receiver gets message in the first step, but the PUBREC message gets lost?

Then the sender must retry to send the message.
In this situation, however, we already have sent the message twice what is what we want to avoid.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

So how can we say, that QoS2 guarantees, that a message is sent exactly once?
What important feature I’m still missing?

>Solution :

I think you’re missing this part from the spec:

Until [the receiver] has received the corresponding PUBREL packet, the receiver MUST acknowledge any subsequent PUBLISH packet with the same Packet Identifier by sending a PUBREC. It MUST NOT cause duplicate messages to be delivered to any onward recipients in this case [MQTT-4.3.3-10].

So…the receiver essentially ignores the duplicate PUBLISH packets.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading