Skip to content

MQTT 5.0 Client: Sessions, Reason Codes and 3.1.1 Differences ​

MQTT 5.0 is not just a bigger version number: it writes the reasons for refused connections, failed subscriptions and rejected publishes into the protocol, and adds session expiry and flow-control properties. NetAssistant's 5.0 implementation focuses on what debugging needs most — readable failure reasons and controllable offline sessions — without sacrificing its lightweight footprint.

What 5.0 solves ​

  • Readable failure reasons: the broker returns a specific reason code when it refuses a connection, subscription or publish, instead of a bare "failed"
  • Controllable sessions: session expiry decides how long the broker keeps the session and offline messages after a disconnect
  • Tunable flow control: receive maximum caps how many QoS 1/2 messages may be in flight at once
  • Switchable versions: toggle the same connection configuration between 3.1.1 and 5.0 to compare broker behavior

Supported capabilities ​

CapabilityNetAssistant 5.0Notes
Clean StartSupportedReuses the Clean Session switch in the connection form; clean start is forced when Client ID is empty
Session expirySupportedIn seconds; omitted when empty; 0 expires on disconnect
Receive maximumSupported1–65535; omitted when empty
Connect reason codesSupportedShows the reason code and broker reason string when CONNACK is refused
Subscribe reason codesSupportedShows the exact reason code when SUBACK fails
Publish reason codesSupportedFailure reasons in PUBACK / PUBREC for QoS 1/2
Disconnect reasonsSupportedShows the reason when the broker sends DISCONNECT
QoS / retain / last willSupportedSame behavior as 3.1.1

Advanced features not provided ​

The current version does not offer the following; use MQTTX or another complete implementation when you need them:

  • User properties
  • Will Delay
  • Subscription identifiers
  • Shared subscriptions ($share/...)
  • Other advanced 5.0 features such as topic aliases

Differences from 3.1.1 ​

DimensionMQTT 3.1.1MQTT 5.0
Connection refusedCONNACK return code 1–5Reason code, e.g. 0x86 bad credentials, 0x87 not authorized
Subscription failureRejection onlySUBACK reason code that distinguishes permissions, filter and quota
Publish failurePUBACK carries no reason codeMay carry a reason code to pinpoint ACL and topic issues
Session expiryNot available0 or a positive number of seconds
Receive maximumNot available1–65535, optional
Broker-initiated disconnectUsually a plain disconnectMay carry a reason code and reason string

Clean Start and session expiry ​

  • Clean Start on: every connection creates a new session, and the broker discards the old session and its offline messages
  • Clean Start off + session expiry 0: state is kept while connected and cleared on disconnect
  • Clean Start off + session expiry > 0: the broker keeps subscriptions and offline messages until expiry, so a reconnect resumes delivery

To test offline messages, first turn Clean Session (that is, Clean Start) off, set session expiry to 300 seconds, subscribe at QoS 1 and disconnect, then publish to that topic and reconnect to see whether the messages are delivered. Brokers differ in how they implement and cap offline queues, so the broker's behavior is the final word.

When Client ID is empty, 5.0 forces clean start and session expiry has no effect; for a persistent session, fill in a fixed, unique Client ID.

How to set receive maximum ​

Receive maximum tells the broker "how many in-flight QoS 1/2 messages I can handle at once". Leaving it empty is the default; set it on low-spec devices, weak networks or when you need to limit bursts:

  • Small device memory: set 10–50 to lower the concurrent delivery volume
  • Normal desktop debugging: leave it empty and use the broker default
  • Investigating message pile-ups: temporarily set a small value and watch whether the broker delivers within that window

Reason code quick reference ​

Reason codeMeaningTypical scenario
0x84Unsupported protocol versionThe broker does not support 5.0
0x85Client ID not validEmpty, too long or containing invalid characters
0x86Bad username or passwordIncorrect credentials
0x87Not authorizedThe ACL does not allow connecting, subscribing or publishing
0x88Server unavailableMaintenance or overload
0x89Server busyRetry or throttle
0x8ABannedContact the administrator
0x8FTopic filter invalidMalformed wildcard syntax
0x90Topic name invalidThe publish topic is empty or contains wildcards
0x97Quota exceededToo many subscriptions or in-flight messages
0x99Payload format invalidThe broker declared payload validation
0x9FConnection rate exceededReconnecting too quickly

For full troubleshooting steps, see MQTT troubleshooting.

When to choose 5.0 ​

  • You need to distinguish authorization failures, invalid topics, quota limits and other specific causes
  • You need to test offline messages and session expiry
  • You need to limit the broker's concurrent delivery volume
  • The broker and cloud platform explicitly support 5.0

For basic subscribe, publish and TLS debugging, 3.1.1 is entirely sufficient, with simpler logs and broader compatibility.

FAQ ​

Does NetAssistant support the full MQTT 5.0 specification? ​

It covers the basics: version switching, clean start, session expiry, receive maximum and reason codes; advanced features such as user properties, Will Delay, subscription identifiers and shared subscriptions are not provided.

Should I choose 5.0 or 3.1.1? ​

Choose 5.0 for session expiry and specific reason codes; choose 3.1.1 for older devices and brokers or basic debugging.

What value should session expiry have? ​

0 expires on disconnect; for offline message testing, turn Clean Start off and enter a positive number of seconds.

What is receive maximum for? ​

It limits how many QoS 1/2 messages the broker delivers at the same time; leave it empty to use the broker default.

Where can I see the MQTT 5.0 subscribe failure reason code? ​

After the subscription switch waits for SUBACK, failure notifications and logs show the reason code, for example 0x87, 0x8F or 0x97.

Last updated:

Released under the Apache-2.0 License