← Back to the chapter · Previous detail · Next detail →
Technical detail · MQTT Python: Reliable Client Patterns
Selected MQTT reason-code responses
| Version | Value | Response | Next action |
|---|---|---|---|
| 3.1.1 | 0 | Connection Accepted (success; Success) | Subscribe to topics and begin publishing. |
| 3.1.1 | 1 | Unacceptable Protocol Version (error; Protocol) | Upgrade your MQTT client library to support the broker’s required version. |
| 3.1.1 | 2 | Identifier Rejected (error; Identity) | Use a client ID accepted by this broker. MQTT 3.1.1 requires support for IDs of 1–23 alphanumeric characters; a broker may accept others. |
| 3.1.1 | 3 | Server Unavailable (warning; Server) | Broker is running but cannot serve requests. Retry with exponential backoff. |
| 3.1.1 | 4 | Bad Username or Password (error; Auth) | Check credentials. Ensure username/password are correctly configured. |
| 3.1.1 | 5 | Not Authorized (error; Auth) | Client lacks ACL permissions. Contact broker administrator. |
| 5.0 | 0 | Success (success; Success) | Connection established. Subscribe and publish. |
| 5.0 | 128 | Unspecified Error (error; General) | Generic failure. Check broker logs for details. |
| 5.0 | 129 | Malformed Packet (error; Protocol) | Client sent invalid data. Update your MQTT library. |
| 5.0 | 130 | Protocol Error (error; Protocol) | Protocol violation detected. Check MQTT version compatibility. |
| 5.0 | 131 | Implementation Specific Error (error; General) | Broker-specific issue. Consult broker documentation. |
| 5.0 | 132 | Unsupported Protocol Version (error; Protocol) | Broker does not support this MQTT version. Try MQTT 3.1.1. |
| 5.0 | 133 | Client ID Not Valid (error; Identity) | Use a valid client ID. Some brokers reject empty or long IDs. |
| 5.0 | 134 | Bad Username or Password (error; Auth) | Verify credentials match broker configuration. |
| 5.0 | 135 | Not Authorized (error; Auth) | Client authenticated but lacks permission. Check ACLs. |
| 5.0 | 136 | Server Unavailable (warning; Server) | Broker temporarily unavailable. Implement retry with backoff. |
| 5.0 | 137 | Server Busy (warning; Server) | Broker overloaded. Back off and retry later. |
| 5.0 | 138 | Banned (error; Auth) | Client has been banned. Contact administrator. |
| 5.0 | 140 | Bad Authentication Method (error; Auth) | Use an authentication method supported by both client and broker. |
| 5.0 | 149 | Packet Too Large (warning; Packet size) | Reduce the packet size or inspect the broker maximum packet size. |
| 5.0 | 151 | Quota Exceeded (warning; Server) | Inspect which resource quota was exceeded; reduce demand or adjust that resource limit. |
| 5.0 | 159 | Connection Rate Exceeded (warning; Server) | Slow down reconnection attempts with exponential backoff. |
| 5.0 | 162 | Wildcard Subscriptions Not Supported (error; Protocol) | Broker disallows wildcards. Use explicit topic names. |