Search code examples
tcpmqttqos

Since MQTT based on TCP, then why MQTT need QoS ?


MQTT is a protocol based on TCP, and, TCP is a reliable transfer protocol.

Since TCP is reliable, then why there's a level 0 QoS in MQTT which represent message from publisher to receiver may lost ?

Or more, since TCP naturally supports reliable transport, then why MQTT need a concept of QoS ?


Solution

  • Say you've written an MQTT message to a TCP link but the TCP link errors out before you receive an acknowledgement for the other end. The other end may or may not have received the MQTT message. An MQTT implementation has to make a decision of whether or not to try to send the message over another link or after the TCP link is re-established. To do this, it needs to know whether the message is essential no matter how much it's delayed or whether there's no point in resending it because it's obsolete if not received promptly.