I have a website where users can upload images to my hosting Apache/PHP server.
If files uploading lasts less than 20 sec everything is fine.
But if it lasts more (no matter what image filesize is), upload fails.
In .htaccess I already have:
php_value upload_max_filesize 10M
php_value post_max_size 70M
php_value max_execution_time 180
php_value max_input_time 180
And in php script, returng result of:
echo "-max_execution_time ".ini_get('max_execution_time');
echo "-max_input_time ".ini_get('max_input_time');
echo "-upload_max_filesize ".ini_get('upload_max_filesize');
echo "-post_max_size ".ini_get('post_max_size');
echo "-memory_limit ".ini_get('memory_limit');
is as excepted:
-max_execution_time 180
-max_input_time 180
-upload_max_filesize 10M
-post_max_size 70M
-memory_limit 128M
These are requests – all failed after 22sec with error net::ERR_SPDY_PROTOCOL_ERROR (in firefox they fail after 20sec)
https://cdn1.imggmi.com/uploads/2019/5/8/fadd31a1a22674cfc3cc4603c97762ff-full.jpg
What I am missing here???
Once again, if uploading duration is less than 20 sec – everything is fine…
5
Answers
It was server problem due shared hosting and I had to contact hosting support...eventually they did some server reconfig and now upload does not break so early...thanks to @m908070 cheers
Maybe This problem stems from “Timeout” Directive in apache httpd.conf file.
See here: https://httpd.apache.org/docs/2.4/mod/core.html#timeout
20 seconds might mean that the Apache module mod_reqtimeout could be what’s killing your request since that is one of it’s defaults (20 seconds to receive request body) if it’s options are not configured.
https://httpd.apache.org/docs/trunk/mod/mod_reqtimeout.html
I believe that mod_reqtimeout is an extension loaded automatically with Apache 2.4
I also encountered a similar problem at my apache2.4-rails-passenger-aws-ec2 project.
When I upload a large file (over 500MB), it times out in about 20 seconds.
I was trying to change apache’s Timeout related configuration, but it didn’t get better.
I switched my application server from apache-passenger to thin, then uploading was no problem.
Since this ask was posted recently, I thought that a recent release of apache had a problem.
After all, I downgraded apache at executing following commands, it’s working properly.
After I read this ask’s answers, I re-upgrade apache to 2.4.39 and commented out the following line to disable mod_reqtimeout, it’s also working.
I think the cause of the problem is in a change of apache through 2.4.38 to 2.4.39.
turning off this module – its help
LoadModule reqtimeout_module modules/mod_reqtimeout.so