Maximum length MQTT payload

0

Hello AWS team!

I'm using AWS IoT Core with an ESP32.

When using MQTT test client with this JSON everything works as expected: { "pattern1": { "name":"Hello", "phases": {"position": "1", "speed":"1", "accel" : "0.2", "delay":"0"}}, "pattern2": { "name":"World", "phases": {"position": "1", "speed":"1", "accel" : "0.2", "delay":"0"}} }

The problem is that I want to send a lot of objects in this JSON, probably 50 or more. When I test it with 3 objects it doesn't work { "pattern1": { "name":"Smooth", "phases": {"position": "1", "speed":"1", "accel" : "0.2", "delay":"0"}}, "pattern2": { "name":"Yanking", "phases": {"position": "1", "speed":"1", "accel" : "0.2", "delay":"0"}}, "pattern3": { "name":"Yanking", "phases": {"position": "1", "speed":"1", "accel" : "0.2", "delay":"0"}} }

I realized that if I reduce the number of words then I'm able to send it, like this: { "1": { "n":"S", "p": {"p": "1", "sp":"1", "a" : "0.2", "d":"0"}}, "2": { "n":"Y", "p": {"p": "1", "s":"1", "a" : "0.2", "d":"0"}}, "3": { "n":"Y", "p": {"p": "1", "s":"1", "a" : "0.2", "d":"0"}}, "4": { "n":"Y"} }

I read that the MQTT payload limit is 128kb, but those 3 objects are smaller than 128kb.

On the ESP32 side, the callback function is triggered as expected. But, when the payload is too big it is not triggering.

Is this an AWS problem related to being able to send those larger payloads?

The AWS region is sa-east-1

Thanks a lot in advance!

gefragt vor einem Jahr1188 Aufrufe
4 Antworten
1

Hi juanGomez. Although IoT Core can handle messages up to 128KB, practical limits, in regards to RAM and buffer sizes on the device, are usually hit first.

Assuming you're using AWS IoT Embedded C SDK libraries, please check the buffer size you are passing into MQTT_Init():

https://aws.github.io/aws-iot-device-sdk-embedded-C/202012.00/libraries/standard/coreMQTT/docs/doxygen/output/html/mqtt_init_function.html.

If your message is bigger than that buffer size, you will have a problem. Although your failed message doesn't look very big.

Are you calling MQTT_Publish() to publish? Are you checking the return value?

https://aws.github.io/aws-iot-device-sdk-embedded-C/202012.00/libraries/standard/coreMQTT/docs/doxygen/output/html/mqtt_publish_function.html.

This call may be failing. Hence the message is perhaps never sent, and that may be why you don't get the callback.

On the cloud side, you can enable AWS IoT logging in CloudWatch to get greater visibility:

https://docs.aws.amazon.com/iot/latest/developerguide/configure-logging.html

profile pictureAWS
EXPERTE
Greg_B
beantwortet vor einem Jahr
0

Thanks a lot for the help.

Problem was that MQTT_MAX_PACKET_SIZE was set to 256 bytes.

I changed it to 65k bytes using setBufferSize() function and it solved the issue.

Thanks a lot

beantwortet vor einem Jahr
  • Glad to hear it. Please don't be shy about accepting answers. We all like a few points.

    65KB is a big buffer by the way. I suspect you probably didn't need to go that big.

0

You are correct about the max payload of an MQTT message being 128KB, and if you were to run up against this limit, you would receive a CLIENT_ERROR with reason of PAYLOAD_LIMIT_EXCEEDED (see references below).

https://docs.aws.amazon.com/iot/latest/developerguide/topicdata.html https://docs.aws.amazon.com/general/latest/gr/iot-core.html#message-broker-limits

I am able to successfully publish the 2nd example you've given above...Are you receiving a payload limit exception error? I suspect there is some other reason you are running into this issue.

Please accept answer if at all helpful!

profile pictureAWS
beantwortet vor einem Jahr
profile picture
EXPERTE
überprüft vor 13 Tagen
0

Hi, I am facing problem to build HTTPS API for AWS IoT core. and Facing problem with GPRS through Arduino. How can I solve this?

beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen