MQTT increasing message size

Hello All,

I have recently started to work on MQTT library and noticed that the maximum message size that can be sent is of 512 bytes. I want to increase the size of this message as i have to send large data arrays, possibly containing thousand values.
Is it do-able? and if not why?

Which library are you using? If it is the one from Hirotakaster (https://github.com/hirotakaster/MQTT/tree/master/src) there is one define in the .h file which you could try to increase to get bigger frames.

Yes, I am using Hirotakaster’s library. The default message size is 255 bytes but using another constructor of .h file, it can be increased to 512 bytes. Can’t it be increased more? Is it because of some limitation in photon?

When you say thousands of values, you might have to consider that there are no general limits for MQTT packets (anything between hundreds of MB down to a few hundred bytes) where the latter is the range you’d have to consider as this is what’s common for IoT. So thousands would be a stretch already, but fitting possibly multiple (lets say) 4KB packets into the Photons RAM would soon exhaust the RAM available - not even considering any demands of non-MQTT related tasks on the same device.

Embedded programming also means dealing with limited resources - not only on the Particle devices but in general.

And the need for keeping things limited especially applies for MQTT brokers that may live in the IoT realm themselves, as they’d have to buffer multiple packets for a “undetermined” time, till they can be delivered.

This discussion touches on that too
https://issues.oasis-open.org/browse/MQTT-271