[英]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.