Php – Long running php script hangs/terminates on IIS 7.5

fastcgiiisiis-7.5PHP

I'm a bit of nube when it comes to configuring IIS 7.5 and Php so apologies if this is a silly question but I've been wrestling with this for over half the day and need some fresh input.

I have a php application running on IIS 7.5 , php 5.4 running as fastcgi. The application works absolutley fine with the exception that long running php scripts seem to hang; no 500 error they simply seem never complete and return the results to the browser.

I've written a simple test script below to eliminate the possibility of programming error in the main app :

<?php
/* test timeout */
/*set_time_limit(110);*/
echo "Testing time out in seconds\n";
for ($i = 0; $i < 175; $i++) {
    echo $i." -- ";

    if(sleep(1)!=0)
    {
        echo "sleep failed script terminating"; 
        break;
    }
}

?>

If I run the script beyond 175 seconds it hangs. Below that it will return the results to the browser.

Here are the time out parameters that I've set for php and fastcgi. I've also played around setting these really low in order to get various time out errors and have succeeded which brings me to the conclusion that there's another setting that I'm missing .. perhaps.

fastcgi

activity timeout=800
Idle Timeout = 900
request Timeout 800

Php

max_execution_time=700

Any solutions or pointers in the right direction would be very … very welcome.

Thanks

Best Answer

It's been a long time since I've dealt with it, but you need to increase the CGI timeouts in IIS as it will simply kill the PHP process if it runs too long.