cURL / Mailing Lists / curl-library / Single Mail

curl-library

Advice on forcing a "Couldn't connect to host" and timeout error.

From: Matt Horrocks <matt.polyvisual_at_gmail.com>
Date: Wed, 11 May 2011 15:47:44 +0100

Hello,

I am trying to work around some intermittent "Couldn't connect to host"
errors which appear when I'm using curl through PHP / curl multi_exec. The
knock on effect of these errors is the length of time curl waits before the
timeout occurs.

I have the following curl_setopt:

curl_setopt($i1, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($i1, CURLOPT_PROXY, $proxy);
curl_setopt($i1, CURLOPT_URL, $url);
curl_setopt($i1, CURLOPT_HEADER, 1);
curl_setopt($i1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($i1, CURLOPT_REFERER, $referer);
curl_setopt($i1, CURLOPT_USERAGENT, $agent);

(I guess) because I don't have CURLOPT_CONNECTTIMEOUT or CURLOPT_TIMEOUT set
that curl just sits and waits for the default timeout to occur before
failing.

I'd like to do some testing rather than just blindly adding
CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT values... so what would be best
way to force a "Couldn't connect to host" timeout error?

Is the error more likely to come from the proxy server or the $url that I'm
try to retrieve or is not possible to tell?

Thanks,
Matt

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-05-11