shadow/update rejected with error 413. JSON size is 44B

0

I'm using an ESP32 as a simple counter and my program has been working for a few months. I made a small change to send more data and I am getting this error. The size of the JSON payload is about 50 only. ** However, the data is being stored as per the rule in my DynamoDB table with no errors.** Why is the information to my device coming back on the rejected topic rather than the accepted one?

14:49:33.250 -> $aws/things/Dev3/shadow/update - {"state": {"reported": {"9": "53,192,1667553572" }}}

14:49:33.250 -> $aws/things/Dev3/shadow/update/rejected - {"code":413,"message":"Json document too large. Size is 8202, max allowed: 8192"}

Thanks

2 Answers
0
Accepted Answer

The issue is that your total shadow document size is larger than 8192, not necessarily the payload you are sending. AWS IoT merges the current payload to the existing shadow document. In your example, the key in the reported is "9". I do not know what that stands for, but in case you have sent updates with multiple key values, eg "8", "10", etc. they all be merged in the shadow document. Please check the shadow document via the console, CLI or an API call (eg https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-rest-api.html#API_GetThingShadow).

To remove the whole shadow content you can use DeleteThingShadow. To remove single keys/fields, just send a JSON document with the field value set to null.

https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-data-flow.html#deleting-thing-data

First, I would check that you are using shadows to store the latest state of the device and not to keep historical data. If that is already the case, you might have too much data too store for a single device shadow. In such case you could consider partitioning the data in multiple named shadows, where each named shadow document has a 8192 bytes limit, but there are no limits on the number of named shadows.

Cheers,

Massimiliano

AWS
EXPERT
answered a year ago
0

Hi. I think you may in fact be sending a document that is 8202 bytes. Perhaps your string isn't null terminated? Can you please use the AWS IoT MQTT client to subscribe to the shadow topic and inspect the message?

the data is being stored as per the rule in my DynamoDB table with no errors

This may not be surprising, depending on the SELECT statement of the rule.

Why is the information to my device coming back on the rejected topic rather than the accepted one?

This is the expected behaviour for an error: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#update-rejected-pub-sub-topic

profile pictureAWS
EXPERT
Greg_B
answered a year ago
  • I am using JSON Serialize to create the payload. After your response, I picked up a sample github code from https://github.com/Savjee/arduino-aws-iot-starter-template/blob/master/arduino-aws-iot-starter-template/arduino-aws-iot-starter-template.ino and ran it with no changes and it throws up the error again

    The MQTT Test Client too show same the same error.

    Please could you help with what else I should look at?

  • Hi. Massimiliano makes a good point, especially if that starter template gets the same error. You can check the shadow by navigating to All devices -> Things -> my-arduino-device -> Device Shadows -> Classic Shadow. Alternatively you can use the AWS CLI (and then inspecting the output.txt file):

    aws iot-data get-thing-shadow --thing-name my-arduino-device output.txt
    

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions