apache - Php curl error : Hostname was NOT found in DNS cache -


i have problem curl request in php script have uploaded on dedicated webserver. know curl request work fine, because have tested on local machine. think problem come apache configuration or on dns. not sure.

when use curl_setopt($ch, curlopt_verbose, true); following error message in test_curlog.log on dedicated server:

* rebuilt url to: http://example.org/ * hostname not found in dns cache * hostname not found in dns cache 

here code use:

<?php var_dump("multi curl request"); $error_curl_log = __dir__ . '/../../../../web/test_curlog.log'; $fp = fopen($error_curl_log, 'a+');  // création des ressources curl $ch2 = curl_init(); $ch3 = curl_init();  // définit l'url ainsi que d'autres options  curl_setopt($ch2, curlopt_url, "http://example.org"); curl_setopt($ch2, curlopt_header, 0); curl_setopt($ch2, curlopt_verbose, true); //for debug curl_setopt($ch2, curlopt_stderr, $fp);  curl_setopt($ch3, curlopt_url, "https://www.googleapis.com/language/translate/v2?key=insert-your-key&source=en&target=de&q=hello%20world"); curl_setopt($ch3, curlopt_header, 0); curl_setopt($ch3, curlopt_verbose, true); //for debug curl_setopt($ch3, curlopt_stderr, $fp);  // création du gestionnaire multiple $mh = curl_multi_init();  // ajoute les deux gestionnaires curl_multi_add_handle($mh, $ch2); curl_multi_add_handle($mh, $ch3);  $active = null; // exécute le gestionnaire {     $mrc = curl_multi_exec($mh, $active); } while ($mrc == curlm_call_multi_perform);  while ($active && $mrc == curlm_ok) {     if (curl_multi_select($mh) != -1) {         {             $mrc = curl_multi_exec($mh, $active);         } while ($mrc == curlm_call_multi_perform);     } } // ferme les gestionnaires curl_multi_remove_handle($mh, $ch2); curl_multi_remove_handle($mh, $ch3); curl_multi_close($mh); die; 

on local machine response on browser: enter image description here

so should same on dedicated server error: maximum execution time of 60 seconds exceeded because curl request doesn't seem find url.

any appreciate.

finally, found solution. consist add condition in while loop:

$mrc === curlm_call_multi_perform || $active 

like this:

$active = null; // exécute le gestionnaire {     $mrc = curl_multi_exec($mh, $active);     // vérification des erreurs     if($mrc > 0) {         // affiche le message d'erreur         echo "erreur !\n " . curl_multi_strerror($mrc);     } } while ($mrc === curlm_call_multi_perform || $active);  while ($active && $mrc == curlm_ok) {     if (curl_multi_select($mh) != -1) {         {             $mrc = curl_multi_exec($mh, $active);         } while ($mrc == curlm_call_multi_perform);     } } 

i don't know why works


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -