首页 > 解决方案 > curl_multi_exec - 部分请求返回 CURLE_COULDNT_RESOLVE_HOST

问题描述

全部!A有问题。我的主机是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

卷曲-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 support => enabled
cURL Information => 7.60.0

在我的脚本中,我使用Zebra_cURL

在我的脚本中:

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);

我的回调:

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/>");
     }
}

问题是通过 CLI 运行 10 次或更多脚本时,某些 URL 会产生错误

“cURL 回应:CURLE_COULDNT_RESOLVE_HOST - https://mylink

错误的数量总是不同的。URL 总是正确的(它们在浏览器中打开)。如果您通过命令行通过 curl 请求相同的 URL,则始终可以正确处理所有内容。

也许有人会告诉我到底是什么问题?

标签: phpcurlcurl-multi

解决方案


推荐阅读