来自 AWS Java 客户端的未知主机异常?

2022-09-04 23:42:03

有没有人遇到过这个例外?我们在昨晚的负载测试中看到了它。主机名正确,通常工作正常。它昨晚刚刚开始抛出这个异常。要么是amanzon的随机DNS失败,要么是Aws SDK for Java在负载下做了一些意想不到的事情。

> Caused by: java.net.UnknownHostException: sdb.amazonaws.com
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:867)
    at java.net.InetAddress.getAddressFromNameService(InetAddress.java:1246)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1197)
    at java.net.InetAddress.getAllByName(InetAddress.java:1128)
    at java.net.InetAddress.getAllByName(InetAddress.java:1064)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:242)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:130)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:561)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:266)

答案 1

在做lein托盘将文件上传到aws桶/或尝试获取远程机器的ips时,我遇到了同样的问题。Caused by: java.net.UnknownHostException: ec2.sa-east-1.amazonaws.com

1. 第一次尝试,

清理项目,等待几分钟/小时,然后使用相同的aws配置重新点火,对我来说很有效。lein pallet up -P aws-ec2

2. 第二次尝试,

运行单个而不是整个群集。lein pallet up -P aws-ec2groups


答案 2

按以下方式更改 /etc/hosts:
旧的
127.0.0.1 localhost localhost.localdomain
new
127.0.0.1 localhost localhost.localdomain add-your-localhost-name-here


推荐