Both versions at once
MQTT 3.1.1 and MQTT 5.0 run simultaneously on the same port, and clients of either version exchange messages freely. The codec encodes and decodes all 15 packet types and validates Variable Byte Integer bounds, duplicate properties and reserved bits.
QoS 0, 1 and 2
Full handshakes, duplicate suppression on QoS 2, and redelivery of unfinished exchanges after a reconnect. Offline queues of persistent sessions survive a broker restart.
Retain and Last Will
A retained-message store with clearing by empty payload, including whole branches, plus Retain Handling 0/1/2 and Retain As Published. The will is sent in every disconnect scenario, including version 5's Will Delay Interval.
Version 5 capabilities
Topic aliases in both directions, Session Expiry, Receive Maximum and flow control, Maximum Packet Size, subscription identifiers, shared subscriptions via $share, No Local, Message Expiry, Payload Format Indicator with UTF-8 validation, Content Type, Response Topic, Correlation Data, User Properties, reason codes in every packet, server-side DISCONNECT and the AUTH packet.
$SYS system topics
Version, uptime and counters for clients, messages, bytes and errors are published as retained messages. The branch is closed by default: wildcards do not reach $ topics, anonymous clients are denied the whole namespace, and a switch in the settings turns publishing off entirely.