Porl123 Posted January 6, 2013 Share Posted January 6, 2013 Hi all, I've got a relatively simple script where I'm trying to perform a multiple curl call to several pages as once. I'm running this in wamp and the cURL extension is definitely enabled and normal curl functions work fine. When I run the script below the page times out: http://pastebin.com/vxMDmnbh I suspect the timeout's being caused by this section here: $active = null; do { $mrc = curl_multi_exec($mh, $active); echo 'g'; } while($mrc == CURLM_CALL_MULTI_PERFORM); while(false && $active && $mrc == CURLM_OK) { if(curl_multi_select($mh) != -1) { do { $mrc = curl_multi_exec($mh, $active); } while($mrc == CURLM_CALL_MULTI_PERFORM); } } But I can't be sure. This is effectively the sample code given on the php.net page and it's not loading. Can anyone spot the problem? Thanks, Paul Quote Link to comment https://forums.phpfreaks.com/topic/272759-timeout-when-using-curl_multi-functions/ Share on other sites More sharing options...
QuickOldCar Posted January 6, 2013 Share Posted January 6, 2013 You can try using Rolling Curl to do this. https://github.com/takinbo/rolling-curl Quote Link to comment https://forums.phpfreaks.com/topic/272759-timeout-when-using-curl_multi-functions/#findComment-1403608 Share on other sites More sharing options...
Porl123 Posted January 6, 2013 Author Share Posted January 6, 2013 Ah, thanks. I'll give that a look at. Quote Link to comment https://forums.phpfreaks.com/topic/272759-timeout-when-using-curl_multi-functions/#findComment-1403609 Share on other sites More sharing options...
Porl123 Posted January 6, 2013 Author Share Posted January 6, 2013 while($active && $mrc == CURLM_OK) { if(curl_multi_select($mh) != -1) { do { $mrc = curl_multi_exec($mh, $active); } while($mrc == CURLM_CALL_MULTI_PERFORM); } } After some more testing it seems the do..while loop is never reached as curl_multi_select($mh) always returns -1. Also the page times out because the condition in the outer while loop is always true "$active && $mrc == CURLM_OK, " although I'm really not sure why that is. Any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/272759-timeout-when-using-curl_multi-functions/#findComment-1403613 Share on other sites More sharing options...
Porl123 Posted January 6, 2013 Author Share Posted January 6, 2013 Found a solution, not sure if it's the most efficient, but it works. http://php.net/manual/en/function.curl-multi-init.php#105252 Quote Link to comment https://forums.phpfreaks.com/topic/272759-timeout-when-using-curl_multi-functions/#findComment-1403622 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.