mqtt.js排队的发布消息数不超过65535 [英] mqtt.js does not queue more than 65535 publish messages

查看:231
本文介绍了mqtt.js排队的发布消息数不超过65535的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用 https://www.npmjs.com/package/mqtt 模拟大量发布,并发现该队列一次最多容纳65535条消息. (如果我尝试发送更多邮件,其余的邮件将被丢弃)是否有此原因,并且有任何解决方法吗?

I've been trying to use https://www.npmjs.com/package/mqtt to simulate a large number of publishes and found that the queue does not hold more than 65535 messages at a time. (If I try to send more, the remaining are discarded) Is there a reason for this and are there any workarounds?

推荐答案

因为这是MQTT中允许的最大数据包ID数

Because that is the maximum number of packet ids allowed in the MQTT spec

数据包ID是一个16位数字(最大65535),并且对于所有机上消息都必须是唯一的.

Packet ids are a 16bit number (max 65535) and must be unique for all inflight messages.

SUBSCRIBE,UNSUBSCRIBE和PUBLISH(在QoS> 0的情况下)控制 包必须包含一个非零的16位包标识符 [MQTT-2.3.1-1].客户端每次发送其中一个的新数据包 键入它必须为其分配一个当前未使用的数据包标识符 [MQTT-2.3.1-2].如果客户端重新发送特定的控制数据包,则 它必须在随后的重发中使用相同的数据包标识符 包.数据包标识符在 客户端已处理了相应的确认数据包.在里面 QoS 1 PUBLISH的情况,这是对应的PUBACK;在这种情况下 QoS 2的值为PUBCOMP.对于SUBSCRIBE或UNSUBSCRIBE,它是 相应的SUBACK或UNSUBACK [MQTT-2.3.1-3].相同条件 当服务器发送QoS> 0 [MQTT-2.3.1-4]的发布消息时,应用于服务器.

SUBSCRIBE, UNSUBSCRIBE, and PUBLISH (in cases where QoS > 0) Control Packets MUST contain a non-zero 16-bit Packet Identifier [MQTT-2.3.1-1]. Each time a Client sends a new packet of one of these types it MUST assign it a currently unused Packet Identifier [MQTT-2.3.1-2]. If a Client re-sends a particular Control Packet, then it MUST use the same Packet Identifier in subsequent re-sends of that packet. The Packet Identifier becomes available for reuse after the Client has processed the corresponding acknowledgement packet. In the case of a QoS 1 PUBLISH this is the corresponding PUBACK; in the case of QoS 2 it is PUBCOMP. For SUBSCRIBE or UNSUBSCRIBE it is the corresponding SUBACK or UNSUBACK [MQTT-2.3.1-3]. The same conditions apply to a Server when it sends a PUBLISH with QoS > 0 [MQTT-2.3.1-4].

这篇关于mqtt.js排队的发布消息数不超过65535的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆