com.amazonaws.SdkClientException:无法执行 HTTP 请求:连接到 dynamodb.ap-southeast-2.amazonaws.com:443

问题描述 投票:0回答:1

我遇到了奇怪的错误,我正在本地运行 spring boot 并连接到 AWS Dynamodb,它返回以下异常:

EVENT>{"@timestamp":"2018-04-03T17:57:33.173+10:00","@Version":1,"message":"与 DynamoDB 创建连接时出错","logger_name":" com.DynamoDBRepository","thread_name":"http-nio-8080-exec-1","level":"错误","level_value":40000,"name":"xyz","apiVersion":"1" ,“应用程序”:“xyz”,“版本”:“1.6.37”,“类型”:“错误”} com.amazonaws.SdkClientException:无法执行 HTTP 请求:连接到 dynamodb.ap-southeast-2.amazonaws.com:443 [dynamodb.ap-southeast-2.amazonaws.com/52.94.13.132] 失败:连接超时 在 com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1069)

连接代码:

ClientConfiguration clientConfiguration = new ClientConfiguration();
        clientConfiguration.withProxyHost("http.com");
        clientConfiguration.withProxyPort(8080);
        clientConfiguration.withProtocol(Protocol.HTTPS);
        clientConfiguration.withProtocol(Protocol.HTTP);
        AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
                .withClientConfiguration(clientConfiguration)
                .withRegion(Regions.AP_SOUTHEAST_2).build();

但是,当我通过公共互联网运行代码时,不会出现此错误。

spring-boot amazon-dynamodb aws-sdk
1个回答
0
投票

有代理

如果您想通过代理设置与 DynamoDB 的连接,请小心配置昂贵的设置:

ClientConfiguration clientConfiguration = new ClientConfiguration();

clientConfiguration.setProxyHost("yourProxyHost");
clientConfiguration.setProxyPort(8080);
clientConfiguration.setProxyUsername("proxyUsername");
clientConfiguration.setProxyPassword("proxyPassword");

   
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
                .withCredentials(new AWSStaticCredentialsProvider(credentials))
                .withClientConfiguration(clientConfiguration)
                .withRegion(Regions.YOUR_REGION)
                .build();

https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/ClientConfiguration.html

无需代理

如果您遇到类似问题但未使用代理连接,那么我建议测试您的主机是否具有有效的互联网网络路径,或者是否在 AWS 上的私有子网中附加了 DynamoDB VPC 端点。

© www.soinside.com 2019 - 2024. All rights reserved.