Fread timeout with 'mod_fcgid: read timeout from channel'

I have a problem with the url where my application is trying to access the timeout. I am trying to catch this timeout and solve this problem using this code:

$timeout = 120; if(false == $handle = @fsockopen($host, $port, $errno, $errstr, $timeout)) { throw new Exception("Could not connect to url: ".$errstr); } $getRequest = "GET {$url} HTTP/1.0\r\n"; $getRequest .= "Host: {$urlParts['host']}\r\n"; $getRequest .= "Connection: close\r\n\r\n"; fwrite($handle, $getRequest); $maxExecutionTime = ini_get('max_execution_time'); set_time_limit($timeout+10); stream_set_timeout($handle, $timeout); $head = fread($handle, 1024); // Read the first 1024 bytes if($maxExecutionTime == 0) { $maxExecutionTime = 30; } set_time_limit($maxExecutionTime); $stream_metadata = stream_get_meta_data($handle); if($stream_metadata['timed_out'] === true) { throw new Exception("Connection timed out"); } 

My URL, which I use for the timeout, is behind the firewall, so I can’t use it, but it is designed to sleep () for 5 minutes. When I try to run this code, execution stops at $ head = fread ($ handle, 1024); and after 90 seconds I get 500 errors from the Premature End of Script server. When I examine the debugging level in apache logs, I see:

 [Fri Aug 26 11:10:45 2011] [warn] [client 192.168.10.202] mod_fcgid: read timeout from pipe [Fri Aug 26 11:10:45 2011] [error] [client 192.168.10.202] Premature end of script headers: validateUrl.php 

with 'validateUrl.php' being the url I am accessing this script through. I am not sure if increasing FcgidIOTimeout to a higher value is safe, as it applies to all my pages. Any ideas / comments?

System Information: PHP version 5.2.13, running Windows NT EPG-WEB 5.2 build 3790 Apache: Apache / 2.2.19 (Win32) mod_fcgid / 2.3.6

+4
source share
1 answer

Try some of these directives in your httpd.conf:

 <IfModule fcgid_module> FcgidIOTimeout 1200 FcgidConnectTimeout 1200 FcgidBusyScanInterval 1200 FcgidBusyTimeout 1200 FcgidErrorScanInterval 1200 FcgidIdleScanInterval 1200 FcgidIdleTimeout 1200 FcgidProcessLifeTime 3600 FcgidZombieScanInterval 1200 </IfModule> 

source: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html

+12
source

Source: https://habr.com/ru/post/1369087/


All Articles