RDS:无法执行 HTTP 请求:无法识别的 SSL 消息,纯文本连接?
RDS : Unable to execute HTTP request: Unrecognized SSL message, plaintext connection?
请参考以下我用来列出 RDS 中可用日志文件的代码 (Mysql)
AWSCredentials credentials = new BasicAWSCredentials("XXX", "XXX");
AWSCredentialsProvider provider = new StaticCredentialsProvider(credentials);
AmazonRDS rdsClient = AmazonRDSClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("XXXX.us-west-2.rds.amazonaws.com:3306", "us-west-2"))
.withCredentials(provider)
.build();
DescribeDBLogFilesRequest request = new DescribeDBLogFilesRequest();
DescribeDBLogFilesResult response = rdsClient.describeDBLogFiles(request);
List<DescribeDBLogFilesDetails> listOfFiles = response.getDescribeDBLogFiles();
System.out.println(listOfFiles.toString());
System.out.println("Program done");
这是我的 pom.xml 依赖项:
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-rds -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-rds</artifactId>
<version>1.11.101</version>
</dependency>
我在使用上面的代码时遇到异常。
错误在这里:
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("XXXX.us-west-2.rds.amazonaws.com:3306", "us-west-2"))
您正在尝试使用 SDK 连接到实际的 RDS 实例,这不是正确的方法。您需要连接到 RDS Query API Endpoint。这些请求通过 service.
发送
您应该能够简单地使用 .withRegion()
,而不必实际提供端点 URL,因为一个区域内的所有 RDS 实例的端点都是相同的,并且默认区域URL已编码到 SDK 中。
请参考以下我用来列出 RDS 中可用日志文件的代码 (Mysql)
AWSCredentials credentials = new BasicAWSCredentials("XXX", "XXX");
AWSCredentialsProvider provider = new StaticCredentialsProvider(credentials);
AmazonRDS rdsClient = AmazonRDSClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("XXXX.us-west-2.rds.amazonaws.com:3306", "us-west-2"))
.withCredentials(provider)
.build();
DescribeDBLogFilesRequest request = new DescribeDBLogFilesRequest();
DescribeDBLogFilesResult response = rdsClient.describeDBLogFiles(request);
List<DescribeDBLogFilesDetails> listOfFiles = response.getDescribeDBLogFiles();
System.out.println(listOfFiles.toString());
System.out.println("Program done");
这是我的 pom.xml 依赖项:
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-rds -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-rds</artifactId>
<version>1.11.101</version>
</dependency>
我在使用上面的代码时遇到异常。
错误在这里:
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("XXXX.us-west-2.rds.amazonaws.com:3306", "us-west-2"))
您正在尝试使用 SDK 连接到实际的 RDS 实例,这不是正确的方法。您需要连接到 RDS Query API Endpoint。这些请求通过 service.
发送您应该能够简单地使用 .withRegion()
,而不必实际提供端点 URL,因为一个区域内的所有 RDS 实例的端点都是相同的,并且默认区域URL已编码到 SDK 中。