Closed Kushagra0409 closed 10 months ago
This is not really the place for general MQTT questions - one of the resources mentioned in the readme is probably more appropriate. Alternatively the specs are quite readable, or there are heaps of guides (e.g. this).
The DUP flag should be set whenever a PUB packet is retransmitted (with MQTT v5 this only occurs upon connection, with V3 it is permitted to happen at other times but most brokers now follow the v5 rules). Unfortunately the flag is of limited use to the receiver because it may, or may not, have received the message when it was previously transmitted (so it's really only an indication that it's worth checking if the packet has been handled previously). At QOS1 doing this requires info outside of that provided by the protocol (e.g. check database to see if the record is there). As QOS2 we can check if we have sent a PUBREL (should be in the session).
Note that when I say "PUB Packet" I am talking about an MQTT packet (with a specific packet identifier). If you, as an end user, elect to send the same data twice then it is not appropriate to use the DUP flag (you need to implement something to detect dupilicates at the application layer).
You may find my current work implementing this in the v5 client of interest.
I'm going to close this as I believe it was a question, which I have answered.
As per my understanding, DUP flags are sent from the sender (publisher) to the receiver (broker) in QOS1, when it (sender) does not receive acknowledgement in form of PUBACK packet. So the same message is re-sent to the broker with DUP set to true. But do we have any option or functionality to not send these Duplicate messages forward? Please help me understand the overall use of DUP flags, as it seems to be completely ignored in handling of such messages. Also, for testing purposes, is there any way to manually set DUP flag to true from the MQTT client itself?