9 years, 3 months ago.

MQTT lib not supporting payload > 50 byte

I am using the MQTT lib. But unable to post Data more than 50 byte in payload. How to increase that limit of the payload? I have to send More than 200 byte as a payload.

Question relating to:

Sample MQTT program - simple send and receive

1 Answer

8 years, 10 months ago.

If you look into MQTTClient.h you can see that the default API of the client is:

template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE = 100, int MAX_MESSAGE_HANDLERS = 5>

So in order to increase the packet size limit (lets say 500 byte) you could initiate the client in the HelloMQTT example with:

MQTT::Client<MQTTEthernet, Countdown, 500> client = MQTT::Client<MQTTEthernet, Countdown, 500>(lipstick);

Now you can handle messages up to 500 byte.

Thank you for answering, Tobias, I must have missed the question. The packet size for publish includes the MQTT header, including topic name, so that should be taken into account when setting the packet size needed.

posted by Ian Craggs 03 Jan 2016

Hi, what is the max payload/limit can be send to the broker? It is possible to sent .txt file from SD card through MQTT? If yes how it can be implemented?

Cheers

posted by Fawwaz Nadzmy 02 Mar 2017