dusterio/laravel-aws-worker

413 Entity too large?

arthur798 opened this issue · 1 comments

I am having trouble understanding how the way this package works, I send an email with a few attachments, so it does get send to sqs, however when it's being processed by the worker I am getting this issue:

[2019-10-24 10:06:36] production.ERROR: Error executing "SendMessage" on "https://sqs.eu-west-2.amazonaws.com/952502652332/awseb-e-2epdmi3t3g-stack-AWSEBWorkerQueue-15LRTRCTWTMEW"; AWS HTTP error: Client error: `POST https://sqs.eu-west-2.amazonaws.com/952502652332/awseb-e-2epdmi3t3g-stack-AWSEBWorkerQueue-15LRTRCTWTMEW` 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-west-2.amazonaws.com/952502652332/awseb-e-2epdmi3t3g-stack-AWSEBWorkerQueue-15LRTRCTWTMEW\"; AWS HTTP error: Client error: `POST https://sqs.eu-west-2.amazonaws.com/952502652332/awseb-e-2epdmi3t3g-stack-AWSEBWorkerQueue-15LRTRCTWTMEW` 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 /var/app/current/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:195, GuzzleHttp\\Exception\\ClientException(code: 413): Client error: `POST https://sqs.eu-west-2.amazonaws.com/952502652332/awseb-e-2epdmi3t3g-stack-AWSEBWorkerQueue-15LRTRCTWTMEW` resulted in a `413 Request Entity Too Large` response:
HTTP content length exceeded 1662976 bytes.
 at /var/app/current/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113)
[stacktrace]
#0 /var/app/current/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php(100): Aws\\WrappedHttpHandler->parseError(Array, Object(GuzzleHttp\\Psr7\\Request), Object(Aws\\Command), Array)
#1 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(203): Aws\\WrappedHttpHandler->Aws\\{closure}(Array)
#2 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(174): GuzzleHttp\\Promise\\Promise::callHandler(2, Array, Array)
#3 /var/app/current/vendor/guzzlehttp/promises/src/RejectedPromise.php(40): GuzzleHttp\\Promise\\Promise::GuzzleHttp\\Promise\\{closure}(Array)
#4 /var/app/current/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\\Promise\\RejectedPromise::GuzzleHttp\\Promise\\{closure}()
#5 /var/app/current/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(98): GuzzleHttp\\Promise\\TaskQueue->run()
#6 /var/app/current/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(125): GuzzleHttp\\Handler\\CurlMultiHandler->tick()
#7 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\\Handler\\CurlMultiHandler->execute(true)
#8 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\\Promise\\Promise->invokeWaitFn()
#9 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\\Promise\\Promise->waitIfPending()
#10 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\\Promise\\Promise->invokeWaitList()
#11 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\\Promise\\Promise->waitIfPending()
#12 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\\Promise\\Promise->invokeWaitList()
#13 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\\Promise\\Promise->waitIfPending()
#14 /var/app/current/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(58): GuzzleHttp\\Promise\\Promise->wait()
#15 /var/app/current/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(86): Aws\\AwsClient->execute(Object(Aws\\Command))
#16 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/SqsQueue.php(89): Aws\\AwsClient->__call('sendMessage', Array)
#17 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/SqsQueue.php(75): Illuminate\\Queue\\SqsQueue->pushRaw('{\"displayName\":...', NULL)
#18 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Queue.php(44): Illuminate\\Queue\\SqsQueue->push(Object(Illuminate\\Events\\CallQueuedListener), '', NULL)
#19 /var/app/current/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(472): Illuminate\\Queue\\Queue->pushOn(NULL, Object(Illuminate\\Events\\CallQueuedListener))
#20 /var/app/current/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(431): Illuminate\\Events\\Dispatcher->queueHandler('Incase\\\\Listener...', 'handle', Array)
#21 [internal function]: Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}(Object(Illuminate\\Mail\\Events\\MessageSent))
#22 /var/app/current/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(366): call_user_func_array(Object(Closure), Array)
#23 /var/app/current/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(196): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Illuminate\\\\Mail...', Array)

However the actual email is send, but the item is put back in the queue and same errors appear, so it resends the email several times. What could have happened here? Why does it put to the queue but when retrieved from the queue it complain about it being too big?

@arthur798 unfortunately both SQS and SNS have strict limits on message size, so you cannot send big JSON objects or attachments etc. You have to make sure you are sending "clean" jobs that can pull any files later if necessary (eg job starts and then downloads a file from S3) or make database queries to hydrate