0

all! A have a problem. My hosting is godaddy

php -v

ea-php-cli Copyright 2017 cPanel, Inc.
PHP 5.6.36 (cli) (built: May 29 2018 01:55:39) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

curl -V

curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp 
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz 

php -i | grep cURL

cURL support => enabled
cURL Information => 7.60.0

In my script I use Zebra_cURL library

In my script:

for ($i=0;$i<50;$i++)
{
    $query = "https://mylink";
    $positions[$query] = $myData
}

require 'Zebra_cURL.php';
$curl = new Zebra_cURL();
$curl->cache(false);
$curl->get(array_keys($positions), 'workWithPositions', $positions);

My callback:

function workWithPositions($result, $positions) {
    if ($result->response[1] == CURLE_OK) {
        if ($result->info['http_code'] == 200) {
            // mycode
        } else {
            die('Server responded with code ' . $result->info['http_code']);
        }
     } else {
         echo('cURL responded with: ' . $result->response[0]. ' - '.$result->info['original_url']."\n<br/>");
     }
}

The problem is that with 10 and more runs of the script through the CLI, some of the URLs produce an error

"cURL responded with: CURLE_COULDNT_RESOLVE_HOST - https://mylink"

The number of errors is always different. URLs are always correct (they open in the browser). If you request the same URL through curl via the command line, everything is always handled correctly.

Maybe someone will tell me what exactly the problem may be?

Nic3500
  • 8,144
  • 10
  • 29
  • 40
  • Additional information. If i collect error positions in an array, make sleep(5) and once again I start to process "erroneous" URLs, everything passes without errors. – Evgheny Tanasov May 30 '18 at 10:21
  • First, look at logs as they could contain a better error detail. Second, 10 is the [default number of threads](https://stefangabos.github.io/Zebra_cURL/Zebra_cURL/Zebra_cURL.html#var$threads) of the library. As suggested, you could also set a pause between batches with [$pause_interval](https://stefangabos.github.io/Zebra_cURL/Zebra_cURL/Zebra_cURL.html#var$pause_interval). – LMC May 30 '18 at 16:26

0 Answers0