1

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

console log

What I am missing here??? Once again, if uploading duration is less than 20 sec - everything is fine...

Nikola
  • 87
  • 2
  • 7
  • 1
    What is your `max_input_time` set to in `php.ini` – RiggsFolly May 08 '19 at 15:48
  • If PHP is running as FastCGI or FPM, there is additional timeouts at this level too. Do you have total control over your server setup? – Capsule May 09 '19 at 02:52
  • If it's using FPM (it would if it's a fairly new setup), check this out: https://stackoverflow.com/questions/40360922/increase-php-fpm-idle-timeout-setting – Capsule May 09 '19 at 02:53

5 Answers5

1

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

georaldc
  • 1,880
  • 16
  • 24
  • Is there any way I can read this value...using php echo, because I can not access Apache settings (probably because shared hosting)? Here is log from one of failed requests https://cdn1.imggmi.com/uploads/2019/5/9/29b910f9442bb6850f5a83ebafbef62d-full.jpg – Nikola May 08 '19 at 22:25
  • I don't think you can easily see your existing Apache configuration with PHP. See if your host allows htaccess files though. If so, you might be able to configure reqtimeout_module through that – georaldc May 08 '19 at 22:31
  • I tried to put ` RequestReadTimeout header=0 RequestReadTimeout body=0 ` in .htaccess but then I get Internal Server Error – Nikola May 08 '19 at 23:37
  • That usually means apache encountered a syntax error with your configuration (htaccess file). Are you sure you didn't type all that in 1 line? – georaldc May 09 '19 at 00:24
1

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.

$ sudo yum list httpd24
Installed packages
httpd24.x86_64  2.4.39-1.87.amzn1
$ sudo yum erase httpd24 httpd24-tools httpd24-devel
$ sudo yum install httpd24-2.4.38-1.86.amzn1 httpd24-2.4.38-1.86.amzn1 httpd24-devel-2.4.38-1.86.amzn1

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.

# LoadModule reqtimeout_module modules/mod_reqtimeout.so

I think the cause of the problem is in a change of apache through 2.4.38 to 2.4.39.

akkunchoi
  • 33
  • 3
0

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

m908070
  • 70
  • 3
  • @RiggsFolly I don't see httpd.conf in my cpanel/file_manager - it seems that I can not access to it... this settings are available for me: https://cdn1.imggmi.com/uploads/2019/5/8/7d5200e8236f46dd7698e66351b26ec0-full.jpg and https://cdn1.imggmi.com/uploads/2019/5/8/b6fdc5e112293427c1a51810f42421f9-full.jpg – Nikola May 08 '19 at 18:53
  • 1
    As far as i know, httpd.conf file is inaccessible in shared hostings. but maybe you can contact your hosting support. – m908070 May 08 '19 at 19:18
  • exactly, 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...cheers – Nikola May 20 '19 at 20:51
0

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

Nikola
  • 87
  • 2
  • 7
0

turning off this module - its help

LoadModule reqtimeout_module modules/mod_reqtimeout.so