You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mqtt: PUBACK or PUBREC with a failure reason code is treated as success #3164
MqttServerFactory handles an inbound PUBACK or PUBREC from a client (acknowledging a PUBLISH the server sent) without looking at the reason code (line numbers on develop at b1a53e9, approximate: ~1858-1925, ~3860-3871, ~7078-7108).
A PUBREC with a reason code of 0x80 or above is handled like a successful PUBREC: the server sends PUBREL, persists the message as INCOMPLETE and waits for a PUBCOMP that never comes. That stream stalls until the client reconnects.
A PUBACK with a reason code of 0x80 or above counts as delivered and commits the Kafka offset. That part matches the specification (the message is not retried), but the failure is not observable anywhere.
MQTT 5.0 section 4.3.3 (QoS 2) and sections 3.4.2.1 and 3.5.2.1 (PUBACK and PUBREC reason codes): when the receiver answers a QoS 2 PUBLISH with a PUBREC whose reason code is 0x80 or above, the exchange is complete, the sender does not send PUBREL and does not retry. MQTT 3.1.1 has no reason codes.
This was found by reading the code, so the first step is a test that confirms the stall.
Expected
A PUBREC with a reason code of 0x80 or above ends the QoS 2 flow for that message without PUBREL, releases the per-message state, and does not leave the stream waiting for a PUBCOMP.
A PUBACK with a reason code of 0x80 or above completes the message as it does today.
Both cases are made observable through the binding's existing event mechanism if one fits; do not add a new event type or mechanism without raising it first.
MQTT 3.1.1 behavior is unchanged.
Test plan (test-first)
Spec scripts (v5), run through the runtime MqttServerITs and the spec-level ITs:
PUBREC 0x80 (and one other failure code) after a QoS 2 PUBLISH: no PUBREL follows, and a following PUBLISH on the same stream is delivered;
PUBACK 0x80 after a QoS 1 PUBLISH: the next message is delivered and the offset is committed as for a success;
a script for the successful PUBREC path stays as the regression guard.
The first commit contains the failing scripts. Scripts are corrected only when they violate the protocol.
Notes
Found by a clause-by-clause audit of MQTT 3.1.1 and 5.0 conformance, by reading the code. Part of the MQTT conformance work under #512.
Activity