cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Name lookup timing out - why?

From: Broekhuis,Robert R. <BROEKHRR_at_airproducts.com>
Date: Fri, 5 Aug 2005 14:06:58 -0400

Let me first apologize in case my query is not pertinent to this list -
please redirect me if necessary...
I'm working on a utility php script that calls on cURL functions to work
with and analyze urls. Works like a charm, for the most part. However,
I've found that some urls simply do not respond to cURL calls, and are
falsely labeled as errors. These are urls that load into my browser
without fail, yet they consistently give no-response cURL errors. I
haven't been able to detect a pattern. I'm hoping that with the experts
around here, I may find my answer...
An example (the only one I can conjure up right now, in fact) is
http://www.aos.org/ . Both this url and the one to which it redirects
(http://www.aos.org/aos/index.aspx ) give a no load response, whereas
they load rapidly into my browser. The relevant bits of my script are:

$url="http://www.aos.org/";
$ch=curl_init();
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1; .NET CLR 1.1.4322)");
curl_setopt($ch,CURLOPT_TIMEOUT,10);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_URL,$url);
$page=curl_exec($ch);
$status=curl_getinfo($ch,CURLINFO_HTTP_CODE);
 
This returns $status=0, with $page empty.
The useragent string is the same one used by my browser.
The curl_error() function, when called after this code, gives "Name
lookup time-outed".
 
Some more poking around: using php's gethostbyname() function (from the
same server) yields the correct IP for the aos domain: 66.148.40.132 .
But once again, when I use the same script on
$url="http://66.148.40.132/" , I get the same error.
Can you give me any pointers as to how to avoid the problem - a utility
that works almost all the time isn't nearly as good as one that works
without fail :-)
Thanks much
Rob

 
 
Received on 2005-08-05