I'm making a project with MQTT Arduino, but on publish messages i read that it's not possible to publish with qos 1 and 2? It is true? If is not, how can i put qos on publish messages?
1 Answer
What MQTT client are you using?
Paraphrased from the MQTT spec http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718099
The MQTT protocol provides three qualities of service for delivering messages between clients and servers: "at most once", QOS0; "at least once" QOS1; and "exactly once" QOS2. For QOS 1&2: The message must be stored locally at the publisher, until the publisher receives confirmation that the message has been delivered to the receiver. However, for QOS0 there is no storage requirement.
The problem with the Arduino is that there is no large quantity of storage available. If the client is disconnected from the broker while using a QOS of 1 or 2 the client must store the messages until a connection is reestablished and the message transfers are acknowledged. On an Arduino there is no guarantee all the messages can be saved. Consider a sensor node collecting 16-bits (int value) every second. Then supposed the broker goes down over the weekend and a repair person isn’t paid to work on the weekend. That’s two days’ worth of data or 172800 readings or about 1/3 MB (without overhead). The Arduino does not have that much storage.