PhilG
06-13-2005, 06:09 AM
Hiya,
Well I’m a fairly experienced web developer trying to create a http monitor script. Now I’ve built it, and the script runs every 5 minutes. It uses curl to perform a simple http request on a defined url however every now and then I get one of the two different errors (both the same but just a difference with the bytes received).
Operation timed out with 0 out of -1 bytes received
Operation timed out with 55 out of -1 bytes received
It happens about every 1 or 2 times an hour. So lets see the code:
function check_http($server_id)
{
$server = server_details($server_id);
$url = "http://" . $server["domain"] . "/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Advanced Server Monitor');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // times out after 10s
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$curl_content = curl_exec ($ch);
$curl_info = curl_getinfo($ch);
$curl_error = curl_error ($ch);
curl_close ($ch);
if ($curl_error)
{
log_error ($server_id, "HTTP", $curl_error);
return;
}
if (!eregi("^2([0-9]{2})", $curl_info['http_code']))
{
log_error ($server_id, "HTTP", "Error Code: " . $curl_info['http_code']);
return;
}
}
Now its pretty easy the code just retrieves the url and catches the response. The problem lies with $curl_error as that reports the Operation times out error. My question and problem is WHY….
I have checked the http logs and it usually reports a log like this:
206.xxx.xxx.xxx - - [13/Jun/2005:05:05:11 -0500] "GET /status.php HTTP/1.1" 200 55
Notice that its transferred 55 bytes… Also note that there are no errors reported.
So I’m at this stage now stuck with a big problem. If anyone can assist me in debugging this further I would love for you to reply!!!
Well I’m a fairly experienced web developer trying to create a http monitor script. Now I’ve built it, and the script runs every 5 minutes. It uses curl to perform a simple http request on a defined url however every now and then I get one of the two different errors (both the same but just a difference with the bytes received).
Operation timed out with 0 out of -1 bytes received
Operation timed out with 55 out of -1 bytes received
It happens about every 1 or 2 times an hour. So lets see the code:
function check_http($server_id)
{
$server = server_details($server_id);
$url = "http://" . $server["domain"] . "/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Advanced Server Monitor');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // times out after 10s
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$curl_content = curl_exec ($ch);
$curl_info = curl_getinfo($ch);
$curl_error = curl_error ($ch);
curl_close ($ch);
if ($curl_error)
{
log_error ($server_id, "HTTP", $curl_error);
return;
}
if (!eregi("^2([0-9]{2})", $curl_info['http_code']))
{
log_error ($server_id, "HTTP", "Error Code: " . $curl_info['http_code']);
return;
}
}
Now its pretty easy the code just retrieves the url and catches the response. The problem lies with $curl_error as that reports the Operation times out error. My question and problem is WHY….
I have checked the http logs and it usually reports a log like this:
206.xxx.xxx.xxx - - [13/Jun/2005:05:05:11 -0500] "GET /status.php HTTP/1.1" 200 55
Notice that its transferred 55 bytes… Also note that there are no errors reported.
So I’m at this stage now stuck with a big problem. If anyone can assist me in debugging this further I would love for you to reply!!!
