Repository navigation
fix(binding-mqtt): scope maximum packet size and publish qos max to the connection - #3135
Merged
Merged
Conversation
…ish qos max Add paired network and application scripts and IT methods for two connections on one binding where the first declares a small Maximum Packet Size, two sessions reporting different publish QoS maximums, and a CONNECT with a repeated Maximum Packet Size property. These are expected to fail against the current code, which keeps both limits in factory fields shared by every connection on a worker. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUbETLeakPq2hrmVEg
…he connection The client's Maximum Packet Size limits only packets sent to that client (MQTT 5.0 section 3.1.2.11.4), and publish QoS maximum reported by a session applies to that session. Both were factory fields shared by every connection on a worker, so one connection lowered or overwrote the limit for all others. Keep the client's Maximum Packet Size and the session's publish QoS maximum as state of the MqttServer stream, check inbound packets against the server's own limit only, and detect a repeated Maximum Packet Size property with its own mask instead of the Topic Alias Maximum mask. Fixes #3129 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUbETLeakPq2hrmVEg
This was referenced Nov 12, 2026
This was referenced Nov 12, 2026
…tain per connection Add paired network and application scripts and IT methods for a zero or repeated Receive Maximum in CONNECT, a PUBLISH whose payload fits the client's Maximum Packet Size but whose encoded packet does not, and a non-retained PUBLISH on one connection after a retained PUBLISH on another whose session has no retain capability. These are expected to fail against the current code. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUbETLeakPq2hrmVEg
…ize, reset retain Receive Maximum shared a switch case with Maximum Packet Size and was read as a 32-bit packet size. Decode it as its own 16-bit property, with a protocol error for a zero or repeated value. The outbound drop compared only the payload size to the client's Maximum Packet Size. Compare the encoded packet size instead, including payload deferred to later frames, and drop the continuation frames of a dropped message so a partial packet is never written. The publish helper shared by every connection never cleared its retained flag, so a retained PUBLISH on one connection made later PUBLISH packets on the worker appear retained. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUbETLeakPq2hrmVEg
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUbETLeakPq2hrmVEg
…packet size A message too large for the client's Maximum Packet Size is discarded and the server behaves as if it had completed sending it (MQTT 5.0 section 3.1.2.11.4), so the application must still receive the acknowledgement for the dropped QoS 1 message and delivery continues with the next one. Expected to fail against the current code, which leaves the dropped message waiting for an acknowledgement the client never sends. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUbETLeakPq2hrmVEg
…ing maximum packet size A message discarded because it exceeds the client's Maximum Packet Size is treated as if sending had completed (MQTT 5.0 section 3.1.2.11.4). Do not register its packet id for an acknowledgement the client will never send; return the window credit and acknowledge the message to the application as a PUBACK, or PUBREC and PUBCOMP, would have. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUbETLeakPq2hrmVEg
…packet size A QoS 2 message too large for the client's Maximum Packet Size is discarded and the server behaves as if it had completed sending it, so the application must receive the completion for the dropped message, no PUBREL may be sent for it, and delivery continues with the next message. Expected to fail against the current code. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUbETLeakPq2hrmVEg
…pubrel Acknowledging a QoS 2 message dropped for exceeding the client's Maximum Packet Size with an INCOMPLETE flush made the application confirm it, which sends PUBREL to the client for a packet that was never sent. Complete the message directly instead. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUbETLeakPq2hrmVEg
This was referenced Nov 12, 2026
fix(binding-mqtt-kafka): apply qos and no local conditions to retained replay on filter change
#3159
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
MqttServerFactorykept two per-connection limits in fields shared by every connection on a worker:maximumPacketSizewas lowered by every CONNECT carrying Maximum Packet Size and never restored, then applied to inbound packet checks and the outbound PUBLISH drop of all later connections.publishQosMaxwas overwritten by every session BEGIN, so a connection saw whatever the latest session on the worker reported.MQTT 5.0 section 3.1.2.11.4: the Maximum Packet Size in CONNECT is the largest packet the client will accept, so it limits packets sent to that client only. It affects no other connection and does not limit what the server accepts from that client.
Changes:
MqttServerstream.Also fixed here, found while auditing the same code:
retainedflag was never cleared byreset(). The helper is one object shared by every connection on the worker, so a retained PUBLISH made later PUBLISH packets look retained, and a connection whose session has no retain capability was then disconnected for a non-retained PUBLISH.Fixes #3129
Stack
fix/3129-mqtt-per-connection-limits(basedevelop)fix/3130-mqtt-kafka-connack-maximum-qosfix/3131-mqtt-kafka-message-expiry-secondsfix/3132-mqtt-kafka-retained-tombstonefix/3133-mqtt-v4-clean-session-persistenceTest evidence
Test-first: the scripts and IT methods were committed before each fix, so a test commit is red on its own until the fix commit that follows it. In particular
ffd8302dd(QoS 2 scenario) andb2fa16165(its fix) go together, as do9bce44c9e/b3075fd42for QoS 1. Added paired network and application scripts (v5), run byspecs/binding-mqtt.specnetwork and application ITs and by the runtime ITs:connect.max.packet.size.other.connection.publish: first connection declares Maximum Packet Size 50, second declares none and sends a larger PUBLISH.connect.max.packet.size.other.connection.subscribe: same pair, larger PUBLISH delivered to the second connection.session.publish.qos.max.per.connection: two sessions whose application BEGIN reports publish QoS maximum 0 and 2; QoS 1 PUBLISH on the first gets DISCONNECT 0x9b.connect.reject.maximum.packet.size.repeated: repeated Maximum Packet Size gets CONNACK 0x82.connect.reject.receive.maximum.zeroandconnect.reject.receive.maximum.repeated: CONNACK 0x82.connect.max.packet.size.exceeded.by.packet.overhead: limit 25; a 7-byte payload in a 26-byte packet is dropped and an 18-byte packet is delivered.publish.retained.per.connection: a non-retained PUBLISH on a session without retain capability after a retained PUBLISH on another connection is accepted.subscribe.qos1.drop.exceeds.max.packet.size: a QoS 1 message exceeding the limit is dropped, the application still receives its acknowledgement, and the next message is delivered and acknowledged.subscribe.qos2.drop.exceeds.max.packet.size: a QoS 2 message exceeding the limit is dropped, the application receives a direct completion for it, no PUBREL is sent, and the next message completes the normal PUBREC/PUBREL/PUBCOMP exchange.Before the fixes, these failed for the expected reasons: the large PUBLISH was rejected (the publish stream never began), the large delivery was dropped, the QoS 1 PUBLISH was accepted instead of rejected, a repeated Maximum Packet Size and a zero Receive Maximum were accepted, the 26-byte packet was delivered, the non-retained PUBLISH was rejected, and the application never received the acknowledgement for a dropped QoS 1 or 2 message so the next message was never sent.
connect.reject.receive.maximum.repeatedalready passed before its fix, by accident of the shared mask, and stays as a regression guard.The first QoS 2 fix (
b3075fd42) sent INCOMPLETE then COMPLETE for a dropped QoS 2 message; the QoS 2 scenario, written afterwards, showed the INCOMPLETE step is wrong, andb2fa16165corrects it.After the fixes (head
b2fa16165):./mvnw clean verify -pl specs/binding-mqtt.spec,runtime/binding-mqtt -am: BUILD SUCCESS, checkstyle passed.Notes and follow-ups (not fixed here)
🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoUbETLeakPq2hrmVEg