Incorrect(?) handling of 'retain' flag in MQTT 3.1.1
bkupidura opened this issue · comments
zynzel commented
Looks like mochi-co/mqtt
is incorrectly setting retain
flag for published messages in 3.1.1.
Based on MQTT-3.3.1-9
It MUST set the RETAIN flag to 0 when a PUBLISH Packet is sent to a Client because it matches an established subscription regardless of how the flag was set in the message it received [MQTT-3.3.1-9].
So imho broker after receiving retained message, should store it - but packet should have retain
flag set to 0
when publishing to clients, unless packet is really retained (and not live sent).
How mosquitto is handling that:
Scenario 1:
- Client-A subscribes to
test/test
- Client-B sends retained message to
test/test
- Client-A receives message, but retained flag is
0
Scenario 2:
- Client-B sends retained message to
test/test
- Client-A subscribes to
test/test
- Client-A receives message, retained flag set to
1
Currently mochi-co/mqtt
is always setting retained flag to 1
in publish if packet was send with retained flag set (in mqtt 3.1.1).