0x03
communication
protocol_error
ai_generated
true
MQTT CONNACK 返回 0x03(连接被拒绝:服务器不可用),原因是发布数据包过大
MQTT CONNACK with 0x03 (Connection Refused: Server unavailable) due to publish packet too large
ID: communication/mqtt-publish-too-large
80%修复率
86%置信度
1证据数
2024-01-22首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Mosquitto 2.0.18 | active | — | — | — |
| EMQX 5.6 | active | — | — | — |
| HiveMQ 4.27 | active | — | — | — |
| AWS IoT Core MQTT 2024-03 | active | — | — | — |
根因分析
MQTT 代理拒绝了有效载荷超过 CONNACK 中指定的“最大数据包大小”或代理默认限制(通常为 256 KB)的 PUBLISH 数据包。
English
MQTT broker rejects a PUBLISH packet whose payload exceeds the `Maximum Packet Size` specified in the CONNACK or broker default limit, typically 256 KB for many brokers.
官方文档
https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901086解决方案
-
Configure the broker to increase the maximum packet size. For Mosquitto, set `max_packet_size` in mosquitto.conf. For EMQX, set `mqtt.max_packet_size` in emqx.conf.
-
Split large payloads into multiple smaller PUBLISH messages on the client side, and reassemble on the subscriber using a topic-specific convention (e.g., chunked/ prefix).
-
Enable MQTT v5.0 and negotiate the maximum packet size during CONNECT by setting the `Maximum Packet Size` property to a value acceptable to both client and broker.
无效尝试
常见但无效的做法:
-
Increase the broker's memory limit
90% 失败
The error is about packet size limits, not memory. More memory doesn't raise the maximum allowed packet size.
-
Disable QoS 2 on the publisher
85% 失败
QoS level doesn't affect the maximum packet size; even QoS 0 messages are subject to the same limit.
-
Use a different MQTT client library
95% 失败
The limit is enforced by the broker, not the client. A different library won't bypass the broker's restriction.