Jump to content

sbutt

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

sbutt's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. In another example code: <?php // create both cURL resources $ch1 = curl_init(); $ch2 = curl_init(); // set URL and other appropriate options curl_setopt($ch1, CURLOPT_URL, "http://slycl1154.st1.spray.net/dev/sbutt/util/overTure.xml"); curl_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch1, CURLOPT_TIMEOUT, 2); curl_setopt($ch2, CURLOPT_URL, "http://slycl1154.st1.spray.net/dev/sbutt/util/inkToMe.xml"); curl_setopt($ch2, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_TIMEOUT, 2); //create the multiple cURL handle $mh = curl_multi_init(); //add the two handles curl_multi_add_handle($mh,$ch1); curl_multi_add_handle($mh,$ch2); $running=null; //execute the handles do { curl_multi_exec($mh,$running); //sleep(3); echo "Feed :".$running; } while ($running > 0); //close the handles curl_multi_remove_handle($mh,$ch1); curl_multi_remove_handle($mh,$ch1); curl_multi_close($mh); ?> the script just hangs when i run it with specification: PHP Version 5.2.4 curl-7.17.0 The strange thing is when i remove the timeouts curl_setopt($ch1, CURLOPT_TIMEOUT, 2); and curl_setopt($ch2, CURLOPT_TIMEOUT, 2); the script starts working. The mentioned 2 feeds are very small which obviously require time in milliseconds to load and hence no problem comes. But when i change the same code and include for example *www.cnn.com* as one of my urls then problem starts to appear again even with or without timeouts. Another strange thing is that when i run all these above scenarios with older specification: PHP Version 5.1.4 curl-7-15-3 no problem comes. -- Now in the end, could anybody tell me if the problem i have mentioned above is related to specification: PHP Version 5.2.4 curl-7.17.0 and if yes then with PHP or CURL? In my opinion it has something to do with the timeout but then in libcurl or php wrapper? thanks.
  2. Hi, I have tried to find out which particular method is depreciated in curl 7.17.0, that I'm using in my code, but no success . Could anybody please help me out? thanks.
  3. Actually it's not a problem of timeout, because if it is then it should also not work on the other php/curl mentioned version.
  4. I'm executing this code from: http://de2.php.net/manual/de/function.curl-multi-exec.php <?php $connomains = array( "http://www.cnn.com/", "http://www.canada.com/", "http://www.yahoo.com/" ); $mh = curl_multi_init(); foreach ($connomains as $i => $url) { $conn[$i] = curl_init($url); curl_setopt($conn[$i], CURLOPT_TIMEOUT, 15); //added myself curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER, TRUE); curl_multi_add_handle ($mh,$conn[$i]); } // start performing the request do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); while ($active and $mrc == CURLM_OK) { // wait for network if (curl_multi_select($mh) != -1) { // pull in any new data, or at least handle timeouts do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } } if ($mrc != CURLM_OK) { print "Curl multi read error $mrc\n"; } // retrieve data foreach ($connomains as $i => $url) { if (($err = curl_error($conn[$i])) == '') { $res[$i]=curl_multi_getcontent($conn[$i]); } else { print "Curl error on handle $i: $err\n"; } curl_multi_remove_handle($mh,$conn[$i]); curl_close($conn[$i]); } curl_multi_close($mh); print_r($res); ?> but getting this error: Curl error on handle 0: Connection time-out after 15996 ms Curl error on handle 1: Connection time-out after 15996 ms Curl error on handle 2: Connection time-out after 15996 ms. my php version: PHP Version 5.2.4 my curl version: curl-7.17.0 Could anybody tell me why is this error coming? Surprisingly the above code works fine on PHP Version 5.1.4, and curl-7-15-3 thanks in advance.
  5. curl_setopt($ch1, CURLOPT_TIMEOUT, 500/1000); ==> 0.5 seconds This change makes the application hang. If i increase the value to curl_setopt($ch1, CURLOPT_TIMEOUT, 1500/1000); ==> 1.5 seconds This works but then i guess it takes the rounded integeral value that is 1 in this case and leave the rest. In case of 0.5 seconds as there is no integeral value so it hangs. Just my guess.
  6. Hi Folks, I'm using PHP 5.2.4 with curl-7.17.0 patch. Now when I run this following small code snippet, <?php // create both cURL resources $ch1 = curl_init(); $ch2 = curl_init(); // set URL and other appropriate options curl_easy_setopt($ch1, CURLOPT_URL, "http://www.example.com/"); curl_easy_setopt($ch1, CURLOPT_TIMEOUT, 5); curl_easy_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/"); curl_setopt($ch2, CURLOPT_TIMEOUT, 5); curl_setopt($ch2, CURLOPT_HEADER, 0); //create the multiple cURL handle $mh = curl_multi_init(); //add the two handles curl_multi_add_handle($mh,$ch1); curl_multi_add_handle($mh,$ch2); $running=null; //execute the handles do { curl_multi_exec($mh,$running); if($running == 0){ echo "Suleman"; echo "||"; echo $running; } } while ($running > 0); //close the handles curl_multi_remove_handle($mh,$ch1); curl_multi_remove_handle($mh,$ch2); curl_multi_close($mh); ?> I get this error: Fatal error: Call to undefined function curl_easy_setopt() ..at line 7. Now could anybody please tell me how can i use 'curl_easy_setopt()' function with "CURLOPT_TIMEOUT" option? The default curl_setopt() method with simple timeout param provides timeout value only in seconds, where as i want to set the value for the timeout in milliseconds. And i'm opening parallel connections to the urls (multi curl).
  7. Hi Folks, I'm using PHP 5.2.4 with curl-7.17.0 patch. Now when I run this following small code snippet, <?php // create both cURL resources $ch1 = curl_init(); $ch2 = curl_init(); // set URL and other appropriate options curl_easy_setopt($ch1, CURLOPT_URL, "http://www.example.com/"); curl_easy_setopt($ch1, CURLOPT_TIMEOUT, 5); curl_easy_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/"); curl_setopt($ch2, CURLOPT_TIMEOUT, 5); curl_setopt($ch2, CURLOPT_HEADER, 0); //create the multiple cURL handle $mh = curl_multi_init(); //add the two handles curl_multi_add_handle($mh,$ch1); curl_multi_add_handle($mh,$ch2); $running=null; //execute the handles do { curl_multi_exec($mh,$running); if($running == 0){ echo "Suleman"; echo "||"; echo $running; } } while ($running > 0); //close the handles curl_multi_remove_handle($mh,$ch1); curl_multi_remove_handle($mh,$ch2); curl_multi_close($mh); ?> I get this error: Fatal error: Call to undefined function curl_easy_setopt() ..at line 7. Now could anybody please tell me how can i use 'curl_easy_setopt()' function with "CURLOPT_TIMEOUT" option? The default curl_setopt() method with simple timeout param provides timeout value only in seconds, where as i want to set the value for the timeout in milliseconds. And i'm opening parallel connections to the urls (multi curl). thanks.
  8. that's correct that 7.17.0, is the most recent version but it would be nice (just out of curiosity!) to know in which curl version 'cury_easy_setopt()' was introduced or in other words with which i can use: curl_easy_setopt($ch1, CURLOPT_TIMEOUT_MS, 0);' Again it's just out of curiosity!
  9. Thank you indeed for your help! Have you by any chance heard of 'curl_easy_setopt()', becuase it has this parameter 'CURLOPT_TIMEOUT_MS' that can be used to provide timeout in millisecond. But when i do that i get the error : Fatal error: Call to undefined function curl_easy_setopt() .. my current curl version is: curl=/opt/curl-7-15-3. I tried to find out curl release verion that contains curl_easy_setopt() but no success
  10. Thanks for your reply, but could you please write me a small code snipped with more than 1 parallel connections and timeout(in millisecond) for each connection set seperatly, using mcurl? thanks in advance.
  11. Hello Guys, I have heard that in php5 there is a built in support for mCURL or in other words it is possible to open multiple parallel connections with different feeds/urls? Now if the above is true then somebody please also tell me if it is possible to set a timeout (in millisecond) for each single connection as opposed to set a global timeout connection for all the feeds? In Nutt-shell, I want to find out, how this mCURL feature (if possible) handles timeouts on a single feed level? Any small code snippet help would be really appreciated. Thanks.
×
×
  • 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.