gpt4 book ai didi

java - api.api.ai : Temporary failure in name resolution

转载 作者:可可西里 更新时间:2023-11-01 16:40:30 24 4
gpt4 key购买 nike

使用我的代码(如下所示),我随机得到了正确的结果。但大多数时候我都会出错。

异常(exception):

java.net.UnknownHostException: api.api.ai: Temporary failure in name resolution
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
..<snip>...
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at PostJSON.main(PostJSON.java:34)

SSCCE 代码:

private static final String URL = "https://api.api.ai/v1/query?v=20150910";
private static final String ACCESS_CODE = "XXXXXX";
public static final HttpClient client = HttpClientBuilder.create().build();
public static final HttpPost httppost = new HttpPost(URL);

private static final String str_json = "{ query: \"how are you\", lang: \"en\", sessionId: \"somerandomthing\" }";

public static void main(String[] args) {

try {

HttpEntity entity = new ByteArrayEntity(str_json.getBytes("UTF-8"));
httppost.setHeader("Content-Type",
"application/json; charset=utf-8");
httppost.setHeader("Authorization", "Bearer " + ACCESS_CODE);
httppost.setEntity(entity);
HttpResponse response = client.execute(httppost);
String result = EntityUtils.toString(response.getEntity());
System.out.println(result);
} catch (Exception ex) {
ex.printStackTrace();
}
}

NS 查找:

zeek@zeek:$ nslookup api.ai.ai
Server: 127.0.1.1
Address: 127.0.1.1#53

Non-authoritative answer:
Name: api.ai.ai
Address: 92.242.140.21

/ETC/主机

127.0.0.1   localhost
127.0.1.1 zeek

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

注意:它有时确实有效。

请建议我应该检查哪些设置/配置。

另请注意,我对 api.api.ai 的 ping 工作正常。

最佳答案

发布解决方案以帮助面临同样问题的其他人,

按照@Hackerman 的说法:

我的 wifi 扩展器无法处理 IPV6 转换。遇到类似问题时,请务必检查 wifi-extender 规范。

作为解决方案/hack(如果您必须使用 IPV4-only 路由器)在启动 java 时使用以下命令

-DpreferIPv4Stack

关于java - api.api.ai : Temporary failure in name resolution,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45868239/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com