Note that there are some explanatory texts on larger screens.

plurals
  1. POphp single curl works but multi curl doesn't work?
    text
    copied!<p>So I was using ampps and then switched to z-wamp thinking it would solve the issue, but it didn't.</p> <p>I have separate "sites" in my localhost (localhost/site1 &amp; localhost/site2) that I'm trying to send multi curl requests to, but for some odd reason, it's not doing anything! It only works when I do one single curl to one site. This works:</p> <pre><code>$ch = curl_init('http://localhost/site1/'); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER =&gt; true, CURLOPT_HEADER =&gt; false, CURLOPT_POST =&gt; true, CURLOPT_POSTFIELDS =&gt; array('data' =&gt; $data) )); $res = curl_exec($ch); //yay! </code></pre> <p>In the other hand, this doesn't work:</p> <pre><code>... //add a bunch of curl sessions //to $this-&gt;sessions ... $window = 15; if (count($this-&gt;sessions) &lt; $window) $window = count($this-&gt;sessions); $mh = curl_multi_init(); $site_map = array(); for ($i = 0; $i &lt; $window; ++$i) { curl_multi_add_handle($mh, $this-&gt;sessions[$i]); $site_map[(string) $this-&gt;sessions[$i]] = $i; } $data_results = array(); $running = null; do { $execrun = curl_multi_exec($mh, $running); } while ($execrun === CURLM_CALL_MULTI_PERFORM); while ($running &amp;&amp; $execrun === CURLM_OK) { //the loop just keeps going forever from here if (curl_multi_select($mh) !== -1) { do { $execrun = curl_multi_exec($mh, $running); } while ($execrun === CURLM_CALL_MULTI_PERFORM); } if ($execrun !== CURLM_OK) break; //to here and never enters the loop below while ($done = curl_multi_info_read($mh)) { $output = curl_multi_getcontent($done['handle']); if ($output) $data_results[$site_map[(string) $done['handle']]] = $output; else $data_results[$site_map[(string) $done['handle']]] = null; if (isset($this-&gt;sessions[$i]) &amp;&amp; $i &lt; count($this-&gt;sessions)) { curl_multi_add_handle($mh, $this-&gt;sessions[$i]); $site_map[(string) $this-&gt;sessions[$i]] = $i; ++$i; } unset($site_map[(string) $done['handle']]); curl_multi_remove_handle($mh, $done['handle']); curl_close($done['handle']); } } curl_multi_close($mh); return $data_results; </code></pre> <p>So in the multi curl code above, it starts going, adds the handles to the $mh, and once it executes, it will keep looping and never go into the $done = curl_multi_info_read($mh) while loop. Meanwhile it is still running fine and also $running equals 2 the whole time. Also, curl_multi_info_read will return false. So it just keeps looping forever.</p> <p>My curl extension is enabled (obviously, if single curl works) and here are the details of it from PHP Info:</p> <pre><code>cURL support enabled cURL Information 7.24.0 Age 3 Features AsynchDNS Yes Debug No GSS-Negotiate No IDN No IPv6 Yes Largefile Yes NTLM Yes SPNEGO No SSL Yes SSPI No krb4 No libz Yes CharConv No Protocols dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp Host i386-pc-win32 SSL Version OpenSSL/1.0.0g ZLib Version 1.2.5 libSSH Version libssh2/1.3.0 </code></pre> <p>What in the world is going on with this thing? Could it be something with my PHP config? Apache config? Once again, I'm using z-wamp.</p> <p>PHP version 5.3.10 Apache version 2.4.1 Win 7 64-bit Added the PHP dir to PATH</p> <p><strong>Edit</strong> It turns out that it must be some kind of Apache/PHP config type issue that I can't spot at all because I did away with z-wamp and installed wampserver and it worked this time.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload