9

MQTT allows senders to set a Quality of Service (QoS) level, which provides certain guarantees about whether a message will be received (and whether duplicates are permitted). This article from HiveMQ highlights the problem of downgrading, where a client with a lower QoS level will not receive the message with the guarantees that the sender requested:

As already said, the QoS flows between a publishing and subscribing client are two different things as well as the QoS can be different. That means the QoS level can be different from client A, who publishes a message, and client B, who receives the published message. Between the sender and the broker the QoS is defined by the sender. When the broker sends out the message to all subscribers, the QoS of the subscription from client B is used.

Does MQTT provide a way of indicating that this downgrade is not acceptable, and that the message must be delivered using the original sender's requested QoS? Is the only option to make sure that both the sender and the receiver have the desired QoS setting before transmitting the message?

2 Answers 2

8

One thing to remember when working with MQTT is that "both subscribers and publishers are considered MQTT clients".

As said QoS set while publishing is entirely related to broker(B) not the other clients. So to ensure that subscriber(S) is receiving everything that publisher(P) is publishing, one need to use QoS 1.

Let's look at cases: P - sends with QoS 0 which means that every message will be at B atmost once ( one time or zero ). In this case if S subscribes to B with QoS 0 -- there is no guarantee that even when the broker (B) receives a message that is going to finally reach S . QoS 1 -- S will definitely receive QoS 2 -- S won't receive multiple messages while broker can

If we do the same with other QoS. We will get to know QoS1 for subscribers works well with all levels as QoS 1 is superset of all.


MQTT does not provide any indication for the same but we can achieve sender's QoS by using QoS 1 while subscribing.

4

QoS 1 or 2 levels only assure that the published message arrived at the broker. The subscriber QoS 1 or 2 assures the broker that the message was received.

Publishing with 1 or 2 does not mean that anyone is listening.

What is your use case?

2
  • 3
    Do not ask questions in answers. If something is not clear leave a comment first. Dec 13, 2016 at 8:28
  • I'm curious about any situation where you might have a sensor sending data to the message broker, then being forwarded to a computer or some other processor where it's vital that the QoS guarantees are kept.
    – Aurora0001
    Dec 13, 2016 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.