The connection will be disconnected after the php executes for more than 300 seconds.

Environment:
win2008 R2 (64-bit) iis7.5 php5.5.38 (nts-vs11-x86)
php operating mode: fastcgi.

Test Code

$start = microtime(true);

set_time_limit(0); //
@ini_set("memory_limit", "-1");//

$file = "./" . time() . ".txt";
for($i = 0; $i < 350; $iPP){
    echo "$i\n";
    ob_flush();
    flush();
    sleep(1);
    file_put_contents($file, $i . ":". round(microtime(true) - $start, 3)."\n", FILE_APPEND);
}

file_put_contents($file, $i . "finished\n", FILE_APPEND);
echo "finished";

problem description:
php script execution more than 300 seconds (300 seconds 320 seconds), tcp connection will be disconnected (more than 300 seconds after the execution of the "netstat-ano | findstr"ip address"" command in cmd, the connection disappears), while the php-cgi.exe is still running (you can see in the iis working process, the test code is still writing files). When the test code is finished ("finished" is written to the file), the browser is still loaded (using wireshark to grab the packet, no server is found to send response data and disconnect the handbag, and the code is normal within 300 seconds).

related configuration:
iis Application Pool:

:

fastcgi:

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters\KeepAliveTime"7200000

win2008 r2

wireshark(300):
wireshark


has not used IIS, but it feels that IIS will have a timeout limit, because both nginx and Apache have such a limit. After php sets time_limit, php will not time out, and you really do not time out, but the browser does not respond, indicating that it should be the problem with web server. You can check


you can use cli mode. There is no limit to the timeout link


if it is necessary for the browser to execute, you need to change the execution time at 00:00, which can be set using the set_time_limit function.


Firewall problem in the computer room where the server is located

Menu