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

curl-and-php

couldn't connect to host, gethostbyname() etc

From: shiplu <shiplu.net_at_gmail.com>
Date: Tue, 25 May 2010 03:00:21 +0600

Hello Everybody,

I am not sure whether anyone faced this problem earlier. Its both
quite rare and wired.

I am curling to a web site. Suppose example.com.

in php when I send request to example.com curl throws "couldn't
connect to host" error. Error No 7. I get this error near about 40% of
the time.
In the mean time I noticed that example.com opens in my firefox
browser fine. and It opens 100% of the time.
Beside this I tried gnu wget command to fetch http://example.com page.
And it works 100% of the time.
And finallly curl cli works too. 100% times !!!!

All of the user-agents works beside my code. And my code works for
every other site except http://example.com

I thought may be curl can not resolve host. I strace'd the commad. And
I saw its not even calling gethostbyname() syscall.
I am not sure where do this curl get address from?? is it from caching?

Note: The site I am working on (example.com) is a high traffic site
and it uses different ip address for same host. But not like facebook,
yahoo or google.

Then I changed each url. Replaced the host part of the url with
corresponding ip address. so http://example.com/path/ looked like
http://192.0.32.10/path/.
And I added "Host:" header manually to each request. As its http/1.1
it should work fine. So it worked according to http/1.1 spec.
I mean curl mimic the same behavior and the error too. :(

Any thought?

Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2010-05-24