Skip to content

Complete client QoS 2 publish on negative MQTT 5 PUBREC - #2273

Draft
YAJeff wants to merge 1 commit into
dotnet:masterfrom
YAJeff:fix/client-negative-pubrec
Draft

YAJeff wants to merge 1 commit into
dotnet:masterfrom
YAJeff:fix/client-negative-pubrec

Conversation

@YAJeff

@YAJeff YAJeff commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

A negative MQTT 5 PUBREC terminates a QoS 2 publish, but the client currently sends PUBREL and waits for PUBCOMP anyway. A broker that releases the rejected exchange can return PacketIdentifierNotFound, masking the original rejection as UnspecifiedError.

Return the original PUBREC reason code, reason string, and ordered user properties without sending PUBREL. Ignore late negative PUBRECs with no awaiter. Successful PUBRECs, including NoMatchingSubscribers, retain the existing handshake; MQTT 3 behavior is unchanged. No public signatures or target frameworks change.

The public wire tests cover all seven negative reason codes, a duplicate negative PUBREC followed by a PING barrier, MQTT 3 and MQTT 5 positive handshakes, and result projection without PUBCOMP. Against master 798a0e2, the unchanged 13-case harness records nine expected failures and four positive passes. This branch passes 13/13 on Linux and Windows under both .NET 8 and .NET 10, using the same Linux-built DLLs on Windows: https://github.com/YAJeff/MQTTnet/actions/runs/36792223162 (public-client-repro and public-client-windows jobs).

Protocol basis: MQTT 5 sections 4.3.3 and 4.4, including MQTT-4.3.3-4 and MQTT-4.4.0-2: https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html

This contribution contains only the client fix and public tests. It has no dependency on custom server persistence adapters. The cited workflow also runs separate fork qualification; those full-suite results are not claimed as upstream-master full-suite validation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant