MQTT标准文档QOS等级容易理解错和surgemq QOS等级的BUG

本文详细解析了MQTT SUBSCRIBE的QoS等级响应规则,包括服务端如何处理订阅请求、QoS等级的匹配与降级。特别指出,服务端在某些情况下可以提供比订阅者请求的QoS更低的等级。同时,文章揭示了surgemq在处理QoS等级上的一个错误行为,即订阅者若订阅QoS0,则无法接收QoS1或QoS2的消息,而mosquitto则不存在此问题。最后,强调了订阅者实际得到的QoS等级可能低于其请求的QoS等级,且服务器可以根据业务需求选择是否降低QoS等级。
摘要由CSDN通过智能技术生成

MQTT SUBSCRIBE 英文原版:

3.8 SUBSCRIBE - Subscribe to topics

3.8.4 Response

When the Server receives a SUBSCRIBE Packet from a Client, the Server MUST respond with a SUBACK Packet [MQTT-3.8.4-1]. The SUBACK Packet MUST have the same Packet Identifier as the SUBSCRIBE Packet that it is acknowledging [MQTT-3.8.4-2].

The Server is permitted to start sending PUBLISH packets matching the Subscription before the Server sends the SUBACK Packet.

If a Server receives a SUBSCRIBE Packet containing a Topic Filter that is identical to an existing Subscription’s Topic Filter then it MUST completely replace that existing Subscription with a new Subscription. The Topic Filter in the new Subscription will be identical to that in the previous Subscription, although its maximum QoS value could be different. Any existing retained messages matching the Topic Filter MUST be re-sent, but the flow of publications MUST NOT be interrupted [MQTT-3.8.4-3].

Where the Topic Filter is not identical to any existing Subscription’s filter, a new Subscription is created and all matching retained messages are sent.

If a Server receives a SUBSCRIBE packet that contains multiple Topic Filters it MUST handle that packet as if it had received a sequence of multiple SUBSCRIBE packets, except that it combines their responses into a single SUBACK response [MQTT-3.8.4-4].

The SUBACK Packet sen

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值