← Back to the chapter · Previous detail
Narrated animation · MQTT QoS Levels
Narrated packet tour
This narrated tour follows one reading, one command and one alarm through the QoS choices, beat by beat, with the packet exchange shown for each.
MQTT QoS narrated tour
Read the full transcript
B1 — Loss consequences
You are the engineer choosing delivery promises for the boiler monitoring system in Bex’s house. A missed temperature reading can be replaced by the next; a missed rare high-temperature alarm can change a safety decision. Should both get the same promise?
B2 — Two delivery legs
Message Queuing Telemetry Transport, or MQTT, lets devices exchange messages. A publisher sends; a broker passes messages to receivers called subscribers. Quality of service, or QoS, names the delivery promise, separately for publisher to broker and broker to subscriber.
B3 — QoS 0: at most once
QoS zero means at most once: a publish packet carries the message without acknowledgement or retry. If lost, it stays lost; replaceable temperature readings can tolerate that.
B4 — QoS 1: at least once
QoS one means at least once. The sender keeps a record until a publish acknowledgement returns. Retrying protects against loss, but duplicates are possible.
B5 — Lost acknowledgement
For your valve commands on plant/boiler7/valve/set, consider a QoS-one lost acknowledgement. The broker receives the publish, but its acknowledgement disappears. After the connection breaks and the session resumes, the publisher resends PUBLISH with the same packet identifier and DUP=1; another acknowledgement returns. Counting only this leg’s QoS exchange, two PUBLISH attempts and two PUBACK attempts make four packet events, including the lost PUBACK; reconnect packets are additional. Delivery succeeded, but a duplicate is possible.
B6 — QoS 2 handshake
QoS two means exactly once at the protocol level. First, the publish message goes from sender to receiver, and a receipt returns. Then a release goes forward, and completion returns. Both sides keep packet-identifier records. If the release is lost, repeating the release completes the stored exchange without another delivery. Extra steps and stored state are the cost.
B7 — Subscriber downgrade
Your subscriber's promise can differ: Subscriber delivery uses the lower of the publication QoS and the maximum QoS granted by the broker in SUBACK. The grant can be lower than requested. With publish QoS two and a successful subscription requesting maximum zero, subscriber delivery is zero; publisher to broker remains two.
B8 — Application outcomes
Does exactly once mean a physical action happened exactly once? No. Protocol delivery does not prove the business result. A repeated toggle command can switch the valve twice. Repeating set valve closed is idempotent: repetition preserves the result. Keep a command identifier and confirm the final valve state on plant/boiler7/valve/state. Assumed duplicate protection cannot prove the valve acted.
B9 — Choose the promise
The smallest promise that fits loss and repetition consequences belongs alongside application duplicate handling and separate proof of the outcome.