Repository navigation
Conversation
MQTT 5 alongside 3.1.1 and 3.1. The protocol version is per connection and only changes the encoding, so clients of different versions talk to each other; a QoS 0 packet is encoded at most once per version. - Properties: full codec with duplicate/zero-value checks; message properties (payload format, content type, response topic, correlation data, user properties) travel with the message, reach OnPublish and are forwarded to MQTT 5 subscribers (dropped for 3.1.1). - Reason codes on PUBACK/PUBREC/PUBCOMP (0x87 for unauthorized publishes, 0x92 for unknown PUBREL), SUBACK, UNSUBACK (0x11 no subscription existed), CONNACK, and DISCONNECT before server-initiated closes: session taken over, keepalive timeout, malformed packet, protocol error, invalid topic alias, subscription identifiers. - Session expiry (CONNECT and DISCONNECT, 0 cannot be raised on DISCONNECT), message expiry (queued, inflight and retained messages; forwarded with the remaining interval), topic aliases from clients, receive maximum (limits the inflight window), maximum packet size in both directions, assigned client IDs, subscription options No Local, Retain As Published and Retain Handling, will delay (cancelled by a reconnect, capped by the session end), DISCONNECT with will message. - Not supported, refused with their reason codes: shared subscriptions (0x9E), subscription identifiers (0xA1), enhanced authentication (0x8C). Session expiry for MQTT 3.1.1 too: Config.SessionExpiry removes sessions offline for longer, with their subscriptions and queues (persistent sessions never expired before), and caps what MQTT 5 clients ask for. New API: Config.SessionExpiry, Config.TopicAliasMaximum, Broker.PublishMessage, Message.Expiry, Message.Properties, Properties, UserProperty, Stats.MessagesExpired, Stats.SessionsExpired. The subscription trie carries per-subscription options and merges overlapping subscriptions during the match; PUBLISH properties are only allocated for MQTT 5 and outgoing PUBLISH buffers are sized up front, so the 3.1.1 hot path makes the same allocations as before (A/B against master: within noise in all three scenarios). Tests: codec tests (portable), 9 MQTT 5 broker tests on both backends; interop with mosquitto_pub/mosquitto_sub -V mqttv5 (properties, 3.1.1 <-> 5, session resume, retained, will delay, shared subscription refused). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #35 +/- ##
==========================================
+ Coverage 74.98% 76.70% +1.72%
==========================================
Files 31 32 +1
Lines 3146 3516 +370
==========================================
+ Hits 2359 2697 +338
- Misses 787 819 +32 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
MQTT 5 alongside 3.1.1/3.1 in the
mqttbroker, plus session expiry for both versions.Interop between versions: the protocol version is per connection and only changes the encoding, so 3.1.1 and 5 clients exchange messages; MQTT 5 message properties are forwarded to MQTT 5 subscribers and dropped for 3.1.1.
MQTT 5 features
Session expiry:
Config.SessionExpiryremoves sessions offline for longer (3.1.1 persistent sessions previously never expired) and caps MQTT 5 requests. Default 0 keeps 3.1.1 spec behaviour; README recommends setting it.New API:
Config.SessionExpiry,Config.TopicAliasMaximum,Broker.PublishMessage,Message.Expiry,Message.Properties,Properties,UserProperty,Stats.MessagesExpired,Stats.SessionsExpired.Performance: A/B against master on the same VM (6 rounds, medians): 100 pubs→1 sub 1.03×, fan-out 10→100 1.02×, 1000 pubs 0.95× with overlapping ranges. Profiles show identical allocations per message and ~84% of CPU in syscalls in both.
Tests: portable codec tests; 9 MQTT 5 broker tests; both backends,
-race; interop withmosquitto_pub/sub -V mqttv5(properties, 3.1.1↔5, session resume, retained, will delay ≈2009 ms for 2 s, reconnect cancels will, shared subscription refused).🤖 Generated with Claude Code