Jump to content

Unique cURL Proxy Issue (VPS Server)


Recommended Posts

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...




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:




//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";



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

    // 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);


    // print output
echo "<br />cURL error number:" .curl_errno($ch);
    echo "<br />cURL error:" . curl_error($ch);
echo "<br />cURL info:";
echo str_pad("
Loaded … ",;
    echo $DLBIGG;


}//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.



The server that is not responding quickly and otherwise timing out: PHP Version 5.2.9



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
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.