Quantcast
Channel: FastCGI Module
Viewing all articles
Browse latest Browse all 205

PHP script hangs after 15 minutes

$
0
0

I have a long-running PHP script, running on IIS (IISEXpress installed via WebMatrix 3.

For the first 15 minutes it works fine, querying the Amazon product advertising API, flushing output to the browser one line at a time to show its progress. Then it stops showing any progress.

I'm fairly sure the issue is not with the script, or Amazon API, because it reaches a different point of progress each time, but always stops at exactly 15 minutes (I have a time built into the script and elapsed time flushed to the page in the browser).

Relevant slice of the log seems to show a 500 error:

2013-10-14 17:51:23.250 ::1 "-" "AMAZON" "-" ::1 GET /index.php - 500 -2147023667 1406 366 104625 12333 "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36" "-" "-" "-" "localhost:12333" 0

2013-10-14 18:06:22.010 ::1 "-" "AMAZON" "-" ::1 GET /index.php - 500 -2147024638 7761 366 41013 12333 "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36" "-" "-" "-" "localhost:12333" 0

The second 500 error after 15 minutes does not always seem to appear; I haven't figured out what's if anything I'm doing differerently when it does.

 

When I run failed request tracing, the output sml does not render prettily, despite the presence of freb.sxl and rendering fine when I test a simple 404 error on the same site. The problem seems to be that that some special character in the data buffer in an event is breaking the XML rendering (in notepad it shows as a left angle bracket and then a square box). I can't show it here as it also breaks this forum's posting mechanism! 

To prevent the script aborting with an error after 30 seconds I set:

set_time_limit(36000); in the script

I heard about IIS maybe having a CGI timeout after 15 minutes, and tried adding the CGI line to ApplicationHostConfig to override any default timeout. No effect. (site name is 'Amazon')

<location path="Amazon"><system.webServer><cgi createCGIWithNewConsole="true" createProcessAsUser="false" timeout="00:20:00" /><handlers><remove name="PHP54_via_FastCGI" /><add name="PHP via FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\iis express\PHP\v5.4\php-cgi.exe" responseBufferLimit="0" resourceType="Either" /></handlers></system.webServer></location>

(If you're wondering, I set ResponseBufferLimit to 0 to enforce flushing.)

Elsewhere in the system.webserver section we have:

<fastCgi><application fullPath="C:\Program Files (x86)\iis express\PHP\v5.4\php-cgi.exe" monitorChangesTo="php.ini" activityTimeout="600" requestTimeout="600" instanceMaxRequests="10000"><environmentVariables><environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" /><environmentVariable name="PHPRC" value="C:\Program Files (x86)\iis express\PHP\v5.4" /></environmentVariables></application></fastCgi>

And elsewhere:

<site name="Amazon" id="2063751105"><application path="/"><virtualDirectory path="/" physicalPath="C:\Users\Jonathan\Documents\My Web Sites\Amazon" /></application><bindings><binding protocol="http" bindingInformation="*:12333:localhost" /></bindings><limits connectionTimeout="00:21:00" /><traceFailedRequestsLogging  enabled="true" /></site>

No other "timeout" values exist.

By the way, I can't run appcmd or access IIS setting by GUI, presumably because of being IISExpress. But applicationhost.config seems to work fine.

Any advice much appreciated.

Jonathan


Viewing all articles
Browse latest Browse all 205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>