Comment 1 for bug 1509083

Revision history for this message
In , Bruno-canet (bruno-canet) wrote :

mod_proxy_fcgi is configured to proxy request to php-fpm as follow:
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/opt/httpd/htdocs/app/$1

If a php script takes more than 30 seconds to execute, a HTTP RC 500 is returned to the client.

php max_execution_time is set to 300 seconds

I used the following script to validate that the error was not due to php max_execution_time issue.

<?php
    error_log("executing script... ");
    $time = time();
    for ($t = 0; $t <= 15; $t++) {
        error_log("Logging: $t (".(time()-$time)." seconds)");
        sleep(5);
    }
    error_log("execution done (".(time()-$time)." seconds)");
?>
after 30 seconds, the HTTP 500 is returned to the client, but in the php error_log the script continue its execution.

According to the documentation, TimeOut is set to 60 seconds by default, so it should not be an issue, but in case, the following explicit definition were tested without improvement:

1. ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/opt/httpd/htdocs/app/$1 timeout=300

2. in virtual host: ProxyTimeout 300

3 in server config: TimeOut 300

The only workaround found was to hardcode the timeout in the mod_proxy_fcgi.c:
--- ./modules/proxy/mod_proxy_fcgi.c.orig 2013-04-16 16:09:25.970332062 +0200
+++ ./modules/proxy/mod_proxy_fcgi.c 2013-04-16 16:09:56.311088966 +0200
@@ -575,7 +575,7 @@
         /* We need SOME kind of timeout here, or virtually anything will
          * cause timeout errors. */
         if (! conn->worker->s->timeout_set) {
- timeout = apr_time_from_sec(30);
+ timeout = apr_time_from_sec(300);
         }

         rv = apr_poll(&pfd, 1, &n, timeout);