I don't understand how I can send a response to avoid Heroku's server error when uploading files that exceed 20mb.
I am using PHP 7.4/Laravel 8.x and I am receiving,
heroku[router]: sock=backend at=error code=H18 desc="Server Request Interrupted" method=POST
An H18 signifies that the socket connected, some data was sent as part of a response by the app, but then the socket was destroyed without completing the response.
It is terminating early due to Heroku's 30 second request limit.
I have configured my .user.ini file,
post_max_size = 100M
upload_max_filesize = 100M
max_input_time = 300
max_execution_time = 300
Am declaring it in the Procfile,
web: vendor/bin/heroku-php-apache2 -i .user.ini public/
I accept multiple files in my form,
<input style="display:none;" type="file" id="files" name="attachment[]" multiple required>
<label for="files" class="files-button" id="filesButton">Upload Images</label>
if the file is an image, I upload it
ini_set('memory_limit', '-1'); // more memory
if($request->hasFile('attachment')) {
$valid_exts = ['png', 'jpg', 'jpeg'];
foreach ($files as $file) {
$extension = $file->getClientOriginalExtension();
if (in_array($extension, $valid_exts)) {
Storage::disk('s3')->put("/model images/$url_name/", $file);
}
}
}
}
Is there any way around this 30 second forced timeout?
I'm running up with the same problem. As you say the connection is interrupted by a section of a large response.
Docs suggest looking through the log files to determine which stage/chunk of the response it threw the error on and fixing that problem.
As far as configuring time out, Heroku says it's not possible.
And suggest using a "direct" file upload, uploading it directly to an S3 from the browser. https://devcenter.heroku.com/articles/s3#file-uploads