node.js MQTT 代理的最大消息长度是多少?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34522053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the maximum message length for a MQTT broker?
提问by user781486
I am using the node.js mosca MQTT broker for some internet of things (iot) application.
我正在将 node.js mosca MQTT 代理用于某些物联网 (iot) 应用程序。
https://github.com/mcollina/mosca
https://github.com/mcollina/mosca
What is the maximum message length that a topic can receive for the mosca broker? What are the factors that constrain the message length?
一个主题可以为 mosca 代理接收的最大消息长度是多少?限制消息长度的因素有哪些?
If I want to increase the message length, is there a configuration parameter I can modify or which part of the code can I change?
如果我想增加消息长度,是否有我可以修改的配置参数或我可以更改代码的哪一部分?
回答by ralight
It's not entirely clear what you're asking here, so I'll answer both possibilities.
不完全清楚你在这里问的是什么,所以我会回答这两种可能性。
The length of the actual topic string is at most 65536 bytes. This is a limit imposed by the mqtt spec, you can't change it. It is also worth noting that the topic is encoded with utf-8, so you may have less than 65536 characters available.
实际主题字符串的长度最多为 65536 字节。这是 mqtt 规范强加的限制,您无法更改它。还值得注意的是,该主题使用 utf-8 编码,因此您可能只有不到 65536 个可用字符。
The payload of the message is limited to 268,435,456 bytes. Again, this is defined by the spec.
消息的有效负载限制为 268,435,456 字节。同样,这是由规范定义的。
If you are routinely approaching either of these limits you should be thinking about whether what you are doing is sensible.
如果您经常接近这些限制中的任何一个,您应该考虑您所做的是否明智。

