What is the maximum message length for a MQTT broker?

user781486 picture user781486 · Dec 30, 2015 · Viewed 31.1k times · Source

I am using the node.js mosca MQTT broker for some internet of things (iot) application.

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?

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?

Answer

ralight picture ralight · Dec 30, 2015

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.

The payload of the message is limited to 268,435,456 bytes. Again, this is defined by the spec.

If you are routinely approaching either of these limits you should be thinking about whether what you are doing is sensible.