March 25th, 2013, 07:57 PM
CURL cannot connect from web server, only from local machine
I don't know if this is the right forum for this, so sorry if it's not. Also, I've replaced the urls with "url blocked" since I can't post the example ones.
$curl_handle = curl_init();
curl_setopt( $curl_handle, CURLOPT_CONNECTTIMEOUT, 10 );
curl_setopt( $curl_handle, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl_handle, CURLOPT_HEADER, 1 );
curl_setopt( $curl_handle, CURLOPT_VERBOSE, 1 );
curl_setopt( $curl_handle, CURLOPT_URL, "url blocked" );
$buffer = curl_exec( $curl_handle );
print_r( curl_getinfo ( $curl_handle ) );
So it seems not to be connecting to the server, yet the identical code works fine from my local machine. Is there any way to get more information? My suspicion is that either my webhost is blocking the outgoing connection or the server I'm trying to connect to is refusing the connection (at one stage a few months back they were doing this but I was at least receiving 403 messages, now I'm getting nothing). I've tried increasing the timeout but same result (with 10 replaced by the timeout in the response). Also, the namelookup_time seems very small, so I wonder if that is failing somehow? The namelookup_time is much smaller than when I connect to google, which works without any problems from the webserver. I've also tried connecting via proxies, with the same results as above.
Array ( [url] => url blocked [content_type] => [http_code] => 0
[header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0
[redirect_count] => 0 [total_time] => 10.00005 [namelookup_time] => 0.001271
[connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0
[speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1
[upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 )
March 25th, 2013, 08:42 PM
Totally the right place.
Outbound blocking is less likely than the remote host blocking the inbound connection (especially if you say they were doing this a while back).
Can you SSH to the machine? From the command line try a wget/curl to that URL and see what happens. It'll probably fail the same way: unable to connect after some amount of time.
Sounds like you can talk to those people. Ask them if you're blocked.
March 26th, 2013, 04:09 AM
I can't use the command line since I'm using shared server hosting and don't have access. I'd also prefer to avoid asking the other server operators if they're blocking me if possible.
Just to confirm though, the results with the proxies and the namelookup_time, are they red herrings? I don't have a lot of experience with these sorts of things.
Are there any other tests I could run to confirm what's happening?
March 26th, 2013, 05:17 AM
The remote host may be whitelisting addresses for who can talk to it - if so then proxies wouldn't make any difference (because they're not on the list either). As for namelookup_time, based on the name I'm going to assume that's DNS lookup so that should always be very small.
There's not a whole lot you can do if you can't get a terminal on the problem computer and you can't get more information from the host.
March 26th, 2013, 07:27 PM
ok, thanks. I'm pretty sure it's not a whitelist since the site is public and receives tens of millions of different connections every week. I guess I'll keep looking/praying.
March 26th, 2013, 09:00 PM
...So what did you mean by
Originally Posted by GGaryG
Originally Posted by GGaryG
March 26th, 2013, 11:48 PM
I'm not sure what you're asking but the millions of connections to the server are not from me because my server is no longer able to connect. The bit you quoted is referring to my circumstances, not anyone else's.
I'm just saying a whitelist seems unlikely since it would be one hell of a long whitelist to maintain.