Understanding mqtt subscriber qos

"Does this mean that the message might not arrive to the client (QOS 0) despite the fact that publisher sent it with QOS 2?"

Yes that is true. The publisher will want to publish at QOS 2 to ensure that the record arrives at the state layer only once (without duplicates). A layer of retrys + acks are used to ensure this. There is additional work for the brokers that provide the topic to subscribing clients to ensure that the message is delivered at the requested QOS level.

For example a message is published at QOS 1 and a subscriber to the same topic is subscribed at QOS 2, then the broker handling the delivery of the message to said subscriber will have to ensure that no duplicate is sent to the client.

In your example a publisher is publishing at QOS 2, so the state layer inserted the record once, and there is a subscriber at QOS 0 for this same topic. The subscriber may never receive this message. For example during message send there was a network hiccup and the record never arrived. Since there is no ack mechanism in QOS 0 the broker never attempts to redeliver.


You are correct, there is no guarantee that a message published at QoS 2 will arrive at a subscriber who is using QoS 0. If it is important for that subscriber to receive the message, they should be using QoS 1 or 2. That is something to decide for any given application.

I would rewrite your definition of QoS 0 as "at most once", i.e. the message will be received or it won't, there isn't a chance of a duplicate.

Regarding default QoS - I think most clients use QoS 0 as the default. I don't see that setting QoS 1 or 2 as the default would help the inexperienced developer, they still need to understand why and what they are doing and to consider the implications on their application.


A publisher really doesn't have a direct notion of what clients are subscribed to that message. A publisher's QOS level determines the quality of service in ensuring that the broker receives the publication. Once the broker receives the publication, it becomes responsible to re-send the message to each of the subscribers at the QOS selected by the respective subscribers. A subscriber can receive a message from the broker at QOS 2, even if the publisher sent it to the broker at QOS 0 or 1.

I found this article quite helpful in understanding this concept.