![](/img/trans.png)
[英]Upgraded aws.java.sdk.version from 1.11.510 to 1.11.825 , now getting error - com.amazonaws.SdkClientException: Failed to connect to service endpoint
[英]Connect to elasticfilesystem.ap-south-1.amazonaws.com:80 failed: Connection refused From Java SDK
我尝试使用 Java Aws sdk 连接 Aws EFS。 但它给了我错误。*
无法执行 HTTP 请求:连接到 elasticfilesystem.ap-south-1.amazonaws.com:80 [elasticfilesystem.ap-south-1.amazonaws.com/52.95.85.30] 失败:连接被拒绝
我没有找到任何关于务实地使用 Efs 执行操作的示例。 有没有代码示例和参考? 我尝试做某事,但我很困惑我是在正确还是错误的轨道上。 在这里我提供我的代码:
AWSCredentials credentials = new BasicAWSCredentials (
"*******************",
"****************************");
ClientConfiguration clientConfig = new ClientConfiguration ();
clientConfig.setProtocol (Protocol.HTTP);
clientConfig.setMaxErrorRetry (DEFAULT_MAX_ERROR_RETRY);
clientConfig.setRetryPolicy (new RetryPolicy (PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION,
DEFAULT_BACKOFF_STRATEGY, DEFAULT_MAX_ERROR_RETRY, false));
AmazonElasticFileSystem fileSystem = AmazonElasticFileSystemClientBuilder.standard ()
.withClientConfiguration (clientConfig)
.withCredentials (new AWSStaticCredentialsProvider (credentials))
.build ();
CreateFileSystemResult result = fileSystem.createFileSystem (new CreateFileSystemRequest ());
System.out.println (result);
基本上 Aws 期望Https协议和生成器的添加区域:
AWSCredentials credentials = new BasicAWSCredentials (
"*******************",
"****************************");
ClientConfiguration clientConfig = new ClientConfiguration ();
clientConfig.setProtocol (Protocol.HTTPS); // make it HTTPS
clientConfig.setMaxErrorRetry (DEFAULT_MAX_ERROR_RETRY);
clientConfig.setRetryPolicy (new RetryPolicy (PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION,
DEFAULT_BACKOFF_STRATEGY, DEFAULT_MAX_ERROR_RETRY, false));
AmazonElasticFileSystem fileSystem = AmazonElasticFileSystemClientBuilder.standard ()
.withClientConfiguration (clientConfig)
.withRegion ("ap-south-1") // add region
.withCredentials (new AWSStaticCredentialsProvider (credentials))
.build ();
CreateFileSystemResult result = fileSystem.createFileSystem (new CreateFileSystemRequest ());
System.out.println (result);
它为我工作。 我希望它会帮助别人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.