mqtt.js does not queue more than 65535 publish messages

扶醉桌前 提交于 2019-12-13 04:26:43

问题


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?


回答1:


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

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

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].



来源:https://stackoverflow.com/questions/51278248/mqtt-js-does-not-queue-more-than-65535-publish-messages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!