laravelaws-lambdaamazon-sqslaravel-excellaravel-vapor

AWS SQS Exception "413 Request Entity Too Large"


I have been stuck for a while to figure out about the below exception any help would be apricated. we are using AWS Lambda service on a Laravel project. and we are exporting a large number of data to CSV files using Laravel Excel and we are doing this through Laravel SQS queues.

php version: 7.2
Laravel Framework: 7.30.1
Laravel Excel : 3.1

Exception:

Aws\Sqs\Exception\SqsException /tmp/vendor/aws/aws-sdk-php...
stage.ERROR: Error executing "SendMessage" on "https://sqs.eu-central- 
1.amazonaws.com"; AWS HTTP error: Client error: `POST https://sqs.eu- 
central-1.amazonaws.com/` resulted in a `413 Request Entity Too Large` 
response:
HTTP content length exceeded 1662976 bytes.
Unable to parse error information from response - Error parsing XML: String could not be parsed as 
XML {"exception":"[object] (Aws\\Sqs\\Exception\\SqsException(code: 0): Error executing      
\"SendMessage\" on \"https://sqs.eu-central-1.amazonaws.com/"; AWS 
HTTP error: Client error: `POST https://sqs.eu-central-1.amazonaws.com/` resulted in a `413 Request Entity Too Large` response:
HTTP content length exceeded 1662976 bytes.
Unable to parse error information from response - Error parsing XML: String could not be parsed as 
XML at /tmp/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:195)
[stacktrace]

Solution

  • From the docs:

    Message size
    The minimum message size is 1 byte (1 character). The maximum is 262,144 bytes (256 KB).

    My guess is that the files you're trying to send are larger than 256KB, which is a hard limit for SQS messages in AWS.

    The output HTTP content length exceeded 1662976 bytes suggests my guess might be correct.

    The common pattern in this case is to upload the files to S3 and send a reference to the object through the Queue.