MySQL_Narb Posted August 12, 2012 Share Posted August 12, 2012 Hi there. I've been experiencing some problems regarding the usage of CURLOPT_CONNECTTIMEOUT. Here's part of my basic proxy tester script: while(count($array) < 4){ $proxy = $proxies[rand(0,count($proxies))]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.REMOVED.org/db/test.php'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.75 Safari/537.1'); curl_setopt($ch, CURLOPT_REFERER, 'http://www.REMOVED.org'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4); $returned = curl_exec($ch); curl_close($ch); if($returned == 'success' && !in_array($proxy, $current_proxies)) $array[] = $proxy; } As you can see, the cURL option CURLOPT_CONNECTTIMEOUT is set to four seconds. However, it still spends more than four seconds on attempting to connect with the specified proxy. I even have it returning proxies that were a success which have connection times of around 7-8+ seconds. Any ideas regarding this? Link to comment https://forums.phpfreaks.com/topic/266965-curlopt_connecttimeout-not-working-properly/ Share on other sites More sharing options...
cpd Posted August 12, 2012 Share Posted August 12, 2012 Your setting the connection time-out as opposed to an execution time-out. How long it takes for a connection to establish is different to how long it takes for a response. The connection could be taking 0.5 seconds to be established whilst the server takes 7 seconds to actually deliver a response. If you were to use the CURL_TIMEOUT option I believe it'll then return false. Link to comment https://forums.phpfreaks.com/topic/266965-curlopt_connecttimeout-not-working-properly/#findComment-1368754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.