Amazon Lex UnknownHostException:runtime.lex.eu-west-1.amazonaws.com

Amazon Lex UnknownHostException: runtime.lex.eu-west-1.amazonaws.com

我编写了一个简单的程序来测试我是否可以使用 Amazon Lex Java API 与我的机器人对话。当我 运行 它时,我得到一个 UnknownHostException: runtime.lex.eu-west-1.amazonaws.com

> Exception in thread "main" com.amazonaws.SdkClientException: Unable to execute HTTP request: runtime.lex.eu-west-1.amazonaws.com
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1114)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1064)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:743)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:717)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access0(AmazonHttpClient.java:667)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
    at com.amazonaws.services.lexruntime.AmazonLexRuntimeClient.doInvoke(AmazonLexRuntimeClient.java:531)
    at com.amazonaws.services.lexruntime.AmazonLexRuntimeClient.invoke(AmazonLexRuntimeClient.java:507)
    at com.amazonaws.services.lexruntime.AmazonLexRuntimeClient.executePostText(AmazonLexRuntimeClient.java:471)
    at com.amazonaws.services.lexruntime.AmazonLexRuntimeClient.postText(AmazonLexRuntimeClient.java:447)
    at ChatBot.ChatbotMain.main(ChatbotMain.java:17)
Caused by: java.net.UnknownHostException: runtime.lex.eu-west-1.amazonaws.com
    at java.net.InetAddress.getAllByName0(InetAddress.java:1280)
    at java.net.InetAddress.getAllByName(InetAddress.java:1192)
    at java.net.InetAddress.getAllByName(InetAddress.java:1126)
    at com.amazonaws.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:27)
    at com.amazonaws.http.DelegatingDnsResolver.resolve(DelegatingDnsResolver.java:38)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:111)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:76)
    at com.amazonaws.http.conn.$Proxy8.connect(Unknown Source)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
    at com.amazonaws.http.apache.client.impl.SdkHttpClient.execute(SdkHttpClient.java:72)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1236)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1056)
    ... 11 more

现在有人知道如何解决这个问题吗? 有没有可能我无法从公司网络发送 HTTP 请求?

代码如下:

package ChatBot;

import com.amazonaws.regions.Regions;
import com.amazonaws.services.lexruntime.AmazonLexRuntime;
import com.amazonaws.services.lexruntime.AmazonLexRuntimeClientBuilder;
import com.amazonaws.services.lexruntime.model.PostTextRequest;
import com.amazonaws.services.lexruntime.model.PostTextResult;

public class ChatbotMain {
    public static void main(String[]args){
        AmazonLexRuntime client = AmazonLexRuntimeClientBuilder.standard().withRegion(Regions.US_EAST_1).build();
        PostTextRequest textRequest= new PostTextRequest();
        textRequest.setBotName("BookTrip");
        textRequest.setBotAlias("BookTripBot");
        textRequest.setUserId("christester");
        textRequest.setInputText("someText");
        PostTextResult result = client.postText(textRequest);
        System.out.println(result.getDialogState());
    }
}

非常感谢,

克里斯

问题是我公司的网络不允许与外部网络服务通信。我必须使用代理或网关才能这样做