This article is contributed. See the original author and article here.

Azure IoT Hub now supports MQTT 5 in public preview. MQTT 5 is the newest version of the protocol and includes many enhancements over version 3.1.1. We’re excited to announce this new IoT Hub capability – it doesn’t replace the existing MQTT 3.1.1 support.


Why MQTT 5

Among all the enhancements, I’m most excited about MQTT 5’s robust support for reason codes. That is, you will be provided with much more clarity on if things are going right, and if not, what’s wrong. For example, if you hit one of IoT Hub’s throttling limits, MQTT 5 protocol has a built-in reason code to tell you about it directly in response:




    QoS: 1
    Packet_Id: 31
    Topic: $iothub/telemetry
    @myProperty1: My String Value # optional
    creation-time: 1600987195320 # optional
    @ No_Rules-ForUser-PROPERTIES: Any UTF-8 string value # optional
    Payload: <data>


Response (throttled):


    Packet_Id: 31
    Reason_Code: 151
    status: 0501


Here, the reason code 151 is the pre-defined code for “quota exceeded” as per spec, and you’ll find the explanation for the 501 status in our docs. The client has much more visibility compared to the MQTT 3.1.1 days, where you may even need to go to our diagnostic logs to get the root cause of an issue!


This is just one example. MQTT 5 for IoT Hub also includes enhancements like:


  • Support for reauthentication before SAS token expiration without disconnecting

  • User properties to store custom key value pairs

  • C2D commands will no longer get purged in absence of subscription from device – they’ll remain queued up until device subscribes or they expire

  • And more!


Getting started

To get started, you’ll need to create a brand new IoT hub with preview mode enabled. This is temporary limitation – once we’re out of preview it will be available to existing IoT hubs as well.


Then, check out our docs on setting up your client for the preview:



Brought to you by Dr. Ware, Microsoft Office 365 Silver Partner, Charleston SC.

%d bloggers like this: