我目前正在将aws-iot-sdk用于Java(v1.11.380),并且在构建AWSIotData和AWSIotClient时,在调试模式下发现了一个隐藏的异常:org.apache.http.conn.ssl.SSLConnectionSocketFactory.<init>(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/HostnameVerifier;)V
我的代码如下:
AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(
new BasicAWSCredentials(configuration.getAccessKeyID(), configuration.getSecretAccessKey()));
AWSIotData awsIotDataClient = AWSIotDataClientBuilder
.standard()
.withCredentials(credentialsProvider)
.build();
AWSIot awsIotClient = AWSIotClientBuilder
.standard()
.withCredentials(credentialsProvider)
.build();
它在第一次构建后会无限期阻塞,如果我切换它们,它也会做同样的事情。
在构造函数(SdkTLSSocketFactory
)中执行super()调用时,问题似乎出在com.amazonaws.http.conn.ssl
包的super(sslContext, hostnameVerifier);
类中
我想这可能是由于Apache http客户端版本与我已经在程序中使用的版本冲突,但是我真的不知道如何解决该问题。
有人可以帮我吗?
谢谢:)
答案 0 :(得分:0)
再过几个小时后,我找到了解决方案。 这是我的pom.xml:
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-iot</artifactId>
<version>1.11.380</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
<version>4.0.2</version>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.5</version>
</dependency>
</dependencies>