MQTT 5.0 消息投递重试及原因码
MQTT 5.0 Message delivery retry and reason code
在 MQTT 5.0 规范中,声明 'If PUBACK or PUBREC is received containing a Reason Code of 0x80 or greater the corresponding PUBLISH packet is treated as acknowledged'
但是在原因代码部分,它指出 'Reason Codes less than 0x80 indicate successful completion of an operation. The normal Reason Code for success is 0. Reason Code values of 0x80 or greater indicate failure.'
他们有什么关系吗?
Q1:为什么 Reason Code 值为 0x80 或更大表示失败,而 PUBACK ontaining Reason Code 为 0x80 或更大被视为已确认?
Q2:另外,PUBACK Reason Code 小于 0x80 的 Reason Code 是否被视为未确认?
Why Reason Code values of 0x80 or greater indicate failure while PUBACK containing a Reason Code of 0x80 or greater is treated as acknowledged?
MQTT-4.4.0-2
的全文是:
If PUBACK or PUBREC is received containing a Reason Code of 0x80 or greater the corresponding PUBLISH packet is treated as acknowledged, and MUST NOT be retransmitted.
这涉及重传;如果 QOS1+ 消息未被确认,将重试(在重新连接时)。 MQTT-4.4.0-2
表示不应重新发送带有指示错误 (0x80+) 的原因代码的 PUBACK
/PUBREC
的接收。
您可能会想到一个可恢复的错误(例如 'broker overloaded'),在该错误中重试该消息是有意义的; MQTT-4.4.0-2
确保规范清楚表明不应重新发送 PUBLISH
。
Besides, does it mean PUBACK containing a Reason Code less than Reason Code of 0x80 is treated as unacknowledged?
否;该句子仅与原因代码 > 0x80 有关。其他地方涵盖了非错误响应 - 例如
[MQTT-4.3.2-3]
In the QoS 1 delivery protocol, the sender MUST treat the PUBLISH packet as “unacknowledged” until it has received the corresponding PUBACK packet from the receiver.
[MQTT-4.3.3-3]
In the QoS 2 delivery protocol, the sender MUST treat the PUBLISH packet as “unacknowledged” until it has received the corresponding PUBREC packet from the receiver.
可以说这两个陈述意味着 MQTT-4.4.0-2 不是必需的,但包含它可确保规范明确说明应如何处理错误。
在 MQTT 5.0 规范中,声明 'If PUBACK or PUBREC is received containing a Reason Code of 0x80 or greater the corresponding PUBLISH packet is treated as acknowledged' 但是在原因代码部分,它指出 'Reason Codes less than 0x80 indicate successful completion of an operation. The normal Reason Code for success is 0. Reason Code values of 0x80 or greater indicate failure.'
他们有什么关系吗?
Q1:为什么 Reason Code 值为 0x80 或更大表示失败,而 PUBACK ontaining Reason Code 为 0x80 或更大被视为已确认?
Q2:另外,PUBACK Reason Code 小于 0x80 的 Reason Code 是否被视为未确认?
Why Reason Code values of 0x80 or greater indicate failure while PUBACK containing a Reason Code of 0x80 or greater is treated as acknowledged?
MQTT-4.4.0-2
的全文是:
If PUBACK or PUBREC is received containing a Reason Code of 0x80 or greater the corresponding PUBLISH packet is treated as acknowledged, and MUST NOT be retransmitted.
这涉及重传;如果 QOS1+ 消息未被确认,将重试(在重新连接时)。 MQTT-4.4.0-2
表示不应重新发送带有指示错误 (0x80+) 的原因代码的 PUBACK
/PUBREC
的接收。
您可能会想到一个可恢复的错误(例如 'broker overloaded'),在该错误中重试该消息是有意义的; MQTT-4.4.0-2
确保规范清楚表明不应重新发送 PUBLISH
。
Besides, does it mean PUBACK containing a Reason Code less than Reason Code of 0x80 is treated as unacknowledged?
否;该句子仅与原因代码 > 0x80 有关。其他地方涵盖了非错误响应 - 例如
[MQTT-4.3.2-3]
In the QoS 1 delivery protocol, the sender MUST treat the PUBLISH packet as “unacknowledged” until it has received the corresponding PUBACK packet from the receiver.
[MQTT-4.3.3-3]
In the QoS 2 delivery protocol, the sender MUST treat the PUBLISH packet as “unacknowledged” until it has received the corresponding PUBREC packet from the receiver.
可以说这两个陈述意味着 MQTT-4.4.0-2 不是必需的,但包含它可确保规范明确说明应如何处理错误。