aws / aws-iot-device-sdk-embedded-C

SDK for connecting to AWS IoT from a device using embedded C.
MIT License
978 stars 625 forks source link

Is QoS > 0 supported in MQTT? #1768

Closed cpp-59487 closed 2 years ago

cpp-59487 commented 2 years ago

Hi,

I am wondering if messages with QoS > 0 are supported? If so, how could I set a timeout on the library so that it knows when to resend these messages when necessary? Thanks.

abhidixi11 commented 2 years ago

Hello @cpp-59487

Yes, it is supported. For QOS > 0, messages would be resent only if the underlying transport connection goes down and the application reconnects to the broker. Since MQTT is implemented over TCP it relies on TCP to handle re-transmission if the packets are lost. Here is the code where the library handles sending of un-acked messages https://github.com/FreeRTOS/coreMQTT/blob/main/source/core_mqtt.c#L279

Please let us know if you have any further questions. Thanks !

cpp-59487 commented 2 years ago

Hi @abhidixi11,

Thanks for the answer. Just wonder, from my understanding, MQTT does not need to be implemented over TCP. Let's say if I would like to have MQTT implemented over UDP, how would the library support the case QoS > 0? Thanks!

abhidixi11 commented 2 years ago

Hello @cpp-59487 Thanks for getting back. MQTT has to be implemented over TCP or over other network protocols that provide ordered, lossless, bi-directional connections. This is from the MQTT spec.. If the protocol is other than TCP then it needs to be lossless and ordered, so UDP is not allowed.

MQTT-SN is another protocol, that is designed for UDP. Please let me know if you have any further questions.

pvyawaha commented 2 years ago

Hello @cpp-59487,

Closing this ticket now, please reopen for the same topic or create a new one for other topics.,