- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我通过 ppp 打开 GSM 连接并尝试使用 curl 从 URL 下载文件。
对于少数设备,curl
和 getaddrinfo
导致 EAI_AGAIN 出现 CURLE_COULDNT_RESOLVE_HOST 错误。
在 route
中,我的 ppp0 接口(interface)注册正确。 resolv.conf 包含 google DNS 并且在终端中手动执行 nslookup
是有效的。
我不知道为什么它不起作用。我唯一知道的是:IPv6 是不可能的。
这是我的getaddrinfo
int checkINet(std::string address)
{
struct addrinfo hints, *servinfo, *p;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
char ip_addr[INET6_ADDRSTRLEN];
int s = getaddrinfo(address.c_str(), NULL, &hints, &servinfo);
if (s != 0)
{
std::cout << "No connection possible: " << address << "\n";
std::cout << "getaddrinfo: " << s << " " << gai_strerror(s) << "\n";
return -1;
}
else
{
std::cout << "Conection successful: " << address << "\n";
for (p = servinfo; p != NULL; p = p->ai_next)
{
void *addr;
if (p->ai_family == AF_INET)
{
struct sockaddr_in *ipv4 =(struct sockaddr_in *)p->ai_addr;
addr = &(ipv4->sin_addr);
}
else
{
struct sockaddr_in6 *ipv6 =(struct sockaddr_in6 *)p->ai_addr;
addr = &(ipv6->sin6_addr);
}
inet_ntop(p->ai_family, addr, ip_addr, sizeof ip_addr);
std::cout << addr << "\n";
}
}
freeaddrinfo(servinfo);
return 0;
}
对于 curl :
CURL *curl;
FILE *fp;
CURLcode res;
// initialise a connection to the server
curl = curl_easy_init();
if (curl)
{
fp = fopen(UPDATE_ZIP, "wb");
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fp);
if (CURLE_OK != res)
{
std::out << "curl failed with: " << res << "\n";
return res;
}
return 0;
}
return -1;
最佳答案
ephemient tipp 是对的。更改了 /etc/nsswitch.con
中的顺序主机:文件 dns到主机:dns 文件
关于c++ - Linux c++ : getaddrinfo failed with EAI_AGAIN, curl 无法解析主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47077846/
在我的代码中,我使用的代码如下。 do { r = getaddrinfo(host, service, &hints, ret); } while (r == EAI_AGAIN); 当测试
我的 Node.js 服务器有时会抛出 EAI_AGAIN 错误,我不知道为什么。我的 Linux 服务器上运行着多个完全不同的 Node 应用程序,当抛出此错误时,它通常会同时在所有应用程序上发生。
我需要在一个小时内执行一百万次 API 调用(服务器可以处理这么多流量),为此,我使用 Node 并行运行多个请求,但是当我尝试运行约 1000 个并发请求时我不断收到这些错误: EAI_AGAIN
我的服务器今天抛出了这个,这是我以前从未见过的 Node.js 错误: Error: getaddrinfo EAI_AGAIN my-store.myshopify.com:443 at O
我知道此错误与DNS查找超时错误有关,这意味着它是网络连接错误或与代理相关的错误。 但是我不知道如何解决它。 我使用docker-compose.yml,里面有3个容器。 这是我的docker-com
我的 nodejs 应用程序连接到外部 url 并使用响应。该应用程序大部分时间都运行良好,但我偶尔会收到 EAI_AGAIN。 error:{code:EAI_AGAIN, errno:EAI_AG
在我的 C++ 应用程序中,我使用 getnameinfo 并返回 EAI_AGAIN - 是什么导致了此错误? struct sockaddr_storage ss; socklen_t salen
我正在通过类(class)学习 Web 开发,是时候使用 Node 包管理器安装 express 了。我必须安装 express 并使用以下命令: npm install express 我得到一个错
大家好,我正在尝试在 npm 中发布我的 angular 库,但是当我登录时,我得到了这个: npm ERR! code EAI_AGAIN npm ERR! errno EAI_AGAIN npm
我正在尝试设置一个临时环境,我可以在其中对 Web 应用程序执行 AT。为了实现这一点,我有 3 个 docker 容器: 容器 1:数据库 (mongo_local) docker build -t
虽然我正在整合 Spotify API进入 Google Assistant应用程序,实现 Account Linking , getaddrinfo EAI_AGAIN api.spotify.co
我通过 ppp 打开 GSM 连接并尝试使用 curl 从 URL 下载文件。 对于少数设备,curl 和 getaddrinfo 导致 EAI_AGAIN 出现 CURLE_COULDNT_RESO
我在我的 Node.js 项目中收到来自 Amazon S3 SDK 的错误,如下所示。 { Error: getaddrinfo EAI_AGAIN ***.s3-accelerate.amazon
我已经在 Docker 容器中设置了 Nodemailer,但我无法发送电子邮件。我在 docker 之外运行了相同的代码来测试它是否有效以及是否发送电子邮件。所以这一定与我的 docker 容器设置
我们用于 facebook messenger 平台的 Node.js 应用抛出以下错误。我们使用“请求”模块连接到 facebook graph api,该模块抛出了这个错误。在我发现问题后大约1小
我的云函数运行了几个月,突然间所有依赖 firebase 身份验证的函数都遇到了这个错误: 'Error while making request: getaddrinfo EAI_AGAINiden
我正在尝试将我的 Strapi 应用程序启动到 Google App Engine,我确实部署成功,但我一直在日志中收到此错误: Server wasn't able to start properl
我正在使用 Windows 7 进行开发。我安装了 node.js 0.12.4,npm 是 2.10.1。 现在我执行 npm intall express --save 但遇到以下错误信息: np
首先,我对部署 CICD 构建完全陌生。 我开始通过这个在 AWS EKS 集群上成功设置 Jenkins X guide . 我能够通过 GitHub 运行管道并在普通的 jx quickstart
yarn 添加 v1.3.2 [1/4] 解析包... 错误 发生意外错误:“https://registry.yarnpkg.com/react:getaddrinfo EAI_AGAIN regi
我是一名优秀的程序员,十分优秀!