soma56 Posted May 16, 2011 Share Posted May 16, 2011 I have a very basic script. It's a cURL script used to grab the contents of a webpage. I'm attempting to connect through a proxy. The most frequent error message I'm receiving is related to a timeout... CURLE_OPERATION_TIMEDOUT (28) After a few hours of trying different things I decided to try a different server. I instantly noticed a huge difference. The script was working correctly through a proxy on SERVER 2. While I did have 'some success' on SERVER 1 I found the results to be slow and inconsistent. Here is a simplified version of the cURL script: <?PHP ignore_user_abort(true); set_time_limit(0); //Proxy Sources $proxypage = file('newproxies.php'); //Assign Page to Download $BIGG = "www.example.com"; //Proxy Sources $proxypage = file('newproxies.php'); $rand_goodproxy = array_rand($proxypage, 2); $goodproxy = $proxypage[$rand_goodproxy[0]] . "\n"; //Variable for User Agent $agent = "My Agent"; ?> <?PHP if(!function_exists('DownloadBIGG')){ function DownloadBIGG($BIGG){ //Globalize variables global $goodproxy, $proxypage, $BIGG, $agent; // is curl installed? if (!function_exists('curl_init')){ die('CURL is not installed!'); } //Start Output Buffer ob_start(); // create a new curl resource $ch = curl_init(); // set URL to download curl_setopt($ch, CURLOPT_URL, $URL); // set referer: curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/"); // user agent: curl_setopt($ch, CURLOPT_USERAGENT, "$agent"); curl_setopt($ch, CURLOPT_PROXY, "$goodproxy"); //Proxy Tunnel? curl_setopt($ch, curlopt_httpproxytunnel, 1); //curl_setopt ($ch, CURLOPT_HTTPGET, true); // remove header? 0 = yes, 1 = no curl_setopt($ch, CURLOPT_HEADER, false); // should curl return or print the data? true = return, false = print curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // sets how long CURL will run before it gives up curl_setopt($ch, CURLOPT_TIMEOUT, 30); // sets how long CURL will wait to even connect curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); // download the given URL, and return output $DLBIGG = curl_exec($ch); //get information $info = curl_getinfo($ch); flush(); ob_flush(); // print output echo "<br />cURL error number:" .curl_errno($ch); echo "<br />cURL error:" . curl_error($ch); echo "<br />cURL info:"; print_r($info); echo str_pad(" Loaded … ",; sleep(1); flush(); ob_end_flush(); echo $DLBIGG; usleep(100000); curl_close($ch); } }//end if !function does not exist global $info, $firstproxy; $DLBIGG = DownloadBIGG($BIGG); ?> Given that trying the script on another server (SERVER 2) led to success with respect to connecting to a proxy I have a strong suspicion that this has something to do with the server configuration. I should point out that the server that I'm having issues with (SERVER 1) is a VPS with over a gig of ram. SERVER 1 The server that is not responding quickly and otherwise timing out: PHP Version 5.2.9 SERVER 2 Responding quickly through the script and returning the page through a proxy: PHP Version 4.4.9 I'd be more then happy to post the "phpinfo();" information for both servers. I'm wondering if there is an obvious setting that I should be adjusting or looking at in terms of the PHP configuration for the server I'm having issues with. Any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/236510-unique-curl-proxy-issue-vps-server/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.