Why Multi Curl returns nothing?

The function works and successfully fulfills many of the requests. But now faced with the fact that when you request the URL it returns void (Herne with him), the error output - the error is not displayed and is not written to the array (tried).
URL returns a void, but only on some Proxy which we substitute.
Here is the code:
spoiler
function MultiRequest ($data)
{
 $multi = curl_multi_init();
 $handles = [];
 $array = [];

 foreach ($data as $key)
{
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, 'https://www.123.ru');
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
 curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');

 curl_setopt($ch, CURLOPT_PROXY, $key["Ip"] . ':' . $key["Port"]);
 curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
 curl_setopt($ch, CURLOPT_TIMEOUT, 30);
 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);

 curl_multi_add_handle($multi, $ch);

 $handles[] = array(
 'url' => $ch,
 'Ip' => $key["Ip"]
);
}

 $active = null;
 do {
 $mrc = curl_multi_exec($multi, $active);
 } while ($mrc == CURLM_CALL_MULTI_PERFORM);


 while ($active && $mrc == CURLM_OK) {
 if (curl_multi_select($multi) == -1) {
usleep(10000);
 // continue; 
}

 do {
 $mrc = curl_multi_exec($multi, $active);
 } while ($mrc == CURLM_CALL_MULTI_PERFORM);

}

 foreach ($handles as $handle)
{
 $result = curl_multi_getcontent($handle["url"]);

 var_dump($result); // here in the derivation of the void

 if (curl_errno($ch)) { // errors not issue.
 echo 'Error:' . curl_error($ch);
}

 curl_multi_remove_handle($multi, $handle["url"]);
}

curl_multi_close($multi);

 return $array;
}


I thought, and decided to try to do exactly the same query, but not Multu curlом, here's a f-tsiya:
spoiler
function Test ()
{
 $array = []; 
 $ch = curl_init();

 curl_setopt($ch, CURLOPT_URL, 'https://www.123.ru');
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

 curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
 curl_setopt($ch, CURLOPT_PROXY, '11.11.11.11:80');
 curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);

 curl_setopt($ch, CURLOPT_TIMEOUT, 30);
 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);

 $result = curl_exec($ch);

var_dump($result);

 if (curl_errno($ch)) {
 echo 'Error:' . curl_error($ch);
}
curl_close($ch);
 return $array;
 }

And to Your surprise this f-tsiya work out successfully! and returns an error:
Error:Received HTTP code 500 from proxy after CONNECT

in Multu curle I'm doing now only 1 query (test) and returns void, and no errors.

Question: what's the problem? a normal curl request we get error, but if multu - no errors and the result is empty.
March 20th 20 at 11:46
1 answer
March 20th 20 at 11:48
Solution
So use the output of the error:
if (curl_errno($ch)) { // errors not issue.
 echo 'Error:' . curl_error($ch);
 }

created curl stream:
if (curl_errno($handle["url"])) { // errors not issue.
 echo 'Error:' . curl_error($handle["url"]);
 }
The result is exactly the same, there are no errors returned void. - nelson.Kuphal commented on March 20th 20 at 11:51
Try curl_multi_errno($handle["url"]), well and suddenly... - America.Hay commented on March 20th 20 at 11:54
@forest_Moo, I get this error:
Fatal error: Call to undefined function curl_multi_errno()

Strange, because this f-tsiya is in php.. it is a pity that only in 7+ versions :) I 5,6 - nelson.Kuphal commented on March 20th 20 at 11:57
@forest_Moo, is multu curl you cannot use curl_errno?? I tried to call curl_error and it showed the error you need. - nelson.Kuphal commented on March 20th 20 at 12:00

Find more questions by tags PHP