Reason Code 与 Properties 目录(MQTT 5)

Reason Code 与 Properties 目录(MQTT 5)

依据 OASIS MQTT 5.0 §2.2.2 Properties§2.4 Reason Code 及各控制报文章节整理
完整规范性定义以正式 HTML/PDF 为准:
https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html
MQTT 3.1.1 本目录所述 Properties / 细粒度 Reason Code 体系


1. Reason Code 使用位置

报文 是否常见带 Reason
CONNACK Connect Reason Code
PUBACK / PUBREC / PUBREL / PUBCOMP 发布流 Reason
SUBACK / UNSUBACK 每订阅/每过滤一项
DISCONNECT 断开原因
AUTH 认证步骤结果

0x00 在多数上下文表示成功;0x80 及以上通常表示错误(具体以该报文章节表格为准)。


2. 常用 Reason Code 速查(跨报文高频)

Code 名称(英文习惯) 典型场景
0x00 Success / Normal disconnection / Granted QoS0 成功
0x01 Granted QoS 1 SUBACK
0x02 Granted QoS 2 SUBACK
0x04 Disconnect with Will Message DISCONNECT
0x10 No matching subscribers PUBACK/PUBREC
0x11 No subscription existed UNSUBACK
0x18 Continue authentication AUTH
0x19 Re-authenticate AUTH
0x80 Unspecified error 多处
0x81 Malformed Packet 解析失败
0x82 Protocol Error 协议违规
0x83 Implementation specific error 实现特定
0x84 Unsupported Protocol Version CONNACK
0x85 Client Identifier not valid CONNACK
0x86 Bad User Name or Password CONNACK
0x87 Not authorized 鉴权失败
0x88 Server unavailable CONNACK
0x89 Server busy CONNACK / DISCONNECT
0x8A Banned CONNACK
0x8B Server shutting down / Keep Alive timeout 视报文
0x8C Bad authentication method CONNACK
0x8D Session taken over DISCONNECT
0x8F Topic Filter invalid SUBACK 等
0x90 Topic Name invalid PUBLISH 相关
0x91 Packet Identifier in use 订阅/发布
0x93 Receive Maximum exceeded 流控
0x94 Topic Alias invalid PUBLISH
0x95 Packet too large 包长
0x97 Quota exceeded 配额
0x99 Payload format invalid 载荷格式
0x9A Retain not supported CONNACK/相关
0x9B QoS not supported CONNACK
0x9C Use another server 重定向
0x9D Server moved 重定向
0x9E Shared Subscriptions not supported SUBACK
0x9F Connection rate exceeded CONNACK
0xA1 Subscription Identifiers not supported SUBACK
0xA2 Wildcard Subscriptions not supported SUBACK

同一数值在不同报文中的官方名称可能略有差别;排障时以该报文章节的 Reason Code 表为准。


3. Property Identifier 目录(常用)

ID 属性名 值类型 典型报文
0x01 Payload Format Indicator Byte PUBLISH, Will
0x02 Message Expiry Interval Four Byte PUBLISH, Will
0x03 Content Type UTF-8 String PUBLISH, Will
0x08 Response Topic UTF-8 String PUBLISH, Will
0x09 Correlation Data Binary PUBLISH, Will
0x0B Subscription Identifier Var Byte Int SUBSCRIBE, PUBLISH
0x11 Session Expiry Interval Four Byte CONNECT, CONNACK, DISCONNECT
0x12 Assigned Client Identifier UTF-8 String CONNACK
0x13 Server Keep Alive Two Byte CONNACK
0x15 Authentication Method UTF-8 String CONNECT, CONNACK, AUTH
0x16 Authentication Data Binary CONNECT, CONNACK, AUTH
0x17 Request Problem Information Byte CONNECT
0x18 Will Delay Interval Four Byte Will Properties
0x19 Request Response Information Byte CONNECT
0x1A Response Information UTF-8 String CONNACK
0x1C Server Reference UTF-8 String CONNACK, DISCONNECT
0x1F Reason String UTF-8 String 多种 ACK/DISCONNECT
0x21 Receive Maximum Two Byte CONNECT, CONNACK
0x22 Topic Alias Maximum Two Byte CONNECT, CONNACK
0x23 Topic Alias Two Byte PUBLISH
0x24 Maximum QoS Byte CONNACK
0x25 Retain Available Byte CONNACK
0x26 User Property UTF-8 String Pair 多处(可重复)
0x27 Maximum Packet Size Four Byte CONNECT, CONNACK
0x28 Wildcard Subscription Available Byte CONNACK
0x29 Subscription Identifier Available Byte CONNACK
0x2A Shared Subscription Available Byte CONNACK

未列出的 Identifier 见规范完整表;实现必须忽略无法识别属性或按规范报错(视报文规则)。


4. 与本库其它文档

主题 文档
报文总结构 10-MQTT控制报文格式总览.md
连接 11
发布/QoS 12
订阅 13
心跳/断开/认证 14
5.0 特性综述 04-MQTT5新特性.md
正式规范链接 09-规范与资料索引.md

5. 合规声明

本目录为便于联调的速查整理。字段强制条件、默认值、哪些属性可重复、错误时关闭连接还是仅丢包等,一律以 OASIS MQTT 5.0 正式文本对应章节的 Normative 表述为准

文章互动

阅读 --

留言

0 条留言

正在加载留言…