IoT Platform supports MQTT 5.0 features that improve transparency and interoperability between devices and the server, including connection feedback, server-sent DISCONNECT packets, and enhanced error codes.
Overview
MQTT 5.0 enhances the following device-cloud interactions:
Feedback on connection establishment
Connection feedback is a negotiation mechanism. The device sends connection parameters during connection, and the server returns a CONNACK packet that confirms the supported features and final parameter values.
|
CONNACK property |
Description and value range |
Response from IoT Platform |
|
Retain Available |
|
1 |
|
Wildcard Subscription Available |
|
1 |
|
Subscription Identifiers Available |
|
0 |
|
Shared Subscription Available |
|
1 |
|
Topic Alias |
|
1 |
|
Maximum QoS |
|
1 |
|
Server Keep Alive |
The keep-alive period during which the server must send heartbeat or data packets. If no packet is sent within this period, the connection is disrupted. Valid values: 30 to 1200. |
Returns the keep-alive period specified by the device. If the device-specified value exceeds the valid range, the connection is disrupted. |
|
Session Expiry Interval |
The session retention period after the connection is disrupted. Valid values: 0 to 0xFFFFFFFF. |
Returns the session retention period specified by the device. Default: 0 (if not specified by the device). |
|
Maximum Packet Size |
Valid values: 0 to 0xFFFFFFFF. |
Always returns 262144 (256 KB). |
|
Topic Alias Maximum |
Valid values: 0 to 0xFFFFFFFF. |
Always returns 20. |
Server-sent DISCONNECT packets
In MQTT 3.1.1, the server closes a device connection without explanation when a rule is violated.
In MQTT 5.0, the server can send a DISCONNECT packet to the device before closing the connection. This packet contains a reason code and reason string, which simplifies troubleshooting.
Enhancements in error codes
|
Enhancement |
MQTT 3.1 |
MQTT 5.0 |
|
Quantity increase |
5 error codes |
20 error codes |
|
Reason string |
Not supported |
Reason String property added for detailed error diagnostics. |
|
Error codes for more types of packets |
Only CONNECT packets return error codes. |
Error codes returned for CONNECT, UNSUBACK, PUBACK, DISCONNECT, and other packets. |
Error codes
|
Decimal |
Hexadecimal |
Name |
Packet type |
|
0 |
0x00 |
Success |
CONNACK, PUBACK, PUBREC, PUBREL, PUBCOMP, UNSUBACK, and AUTH |
|
128 |
0x80 |
Unspecified error |
CONNACK, PUBACK, PUBREC, SUBACK, UNSUBACK, and DISCONNECT |
|
129 |
0x81 |
Malformed Packet |
CONNACK and DISCONNECT |
|
130 |
0x82 |
Protocol Error |
CONNACK and DISCONNECT |
|
132 |
0x84 |
Unsupported Protocol Version |
CONNACK |
|
136 |
0x88 |
Server unavailable |
CONNACK |
|
137 |
0x89 |
Server busy |
CONNACK and DISCONNECT |
|
138 |
0x8A |
Banned |
CONNACK |
|
140 |
0x8C |
Bad authentication method |
CONNACK and DISCONNECT |
|
141 |
0x8D |
Keep Alive timeout |
DISCONNECT |
|
144 |
0x90 |
Topic Name invalid |
CONNACK, PUBACK, PUBREC, and DISCONNECT |
|
147 |
0x93 |
Receive Maximum exceeded |
DISCONNECT |
|
148 |
0x94 |
Topic Alias invalid |
DISCONNECT |
|
149 |
0x95 |
Packet too large |
CONNACK and DISCONNECT |
|
150 |
0x96 |
Message rate too high |
DISCONNECT |
|
151 |
0x97 |
Quota exceeded |
CONNACK, PUBACK, PUBREC, SUBACK, and DISCONNECT |
|
152 |
0x98 |
Administrative action |
DISCONNECT |
|
153 |
0x99 |
Payload format invalid |
PUBACK, PUBREC, and DISCONNECT |
|
154 |
0x9A |
Retain not supported |
CONNACK and DISCONNECT |
|
155 |
0x9B |
QoS not supported |
CONNACK and DISCONNECT |
|
156 |
0x9C |
Use another server |
CONNACK and DISCONNECT |
|
157 |
0x9D |
Server moved |
CONNACK and DISCONNECT |
|
158 |
0x9E |
Shared Subscription not supported |
SUBACK and DISCONNECT |
|
159 |
0x9F |
Connection rate exceeded |
CONNACK and DISCONNECT |