gpt4 book ai didi

java - AWS IoT SDK - 构建 AWSIotData 和 AWSIotClient 时出现异常

转载 作者:太空宇宙 更新时间:2023-11-04 10:16:13 28 4
gpt4 key购买 nike

我目前正在使用适用于 java 的 aws-iot-sdk (v1.11.380),当我构建 AWSIotData 和 AWSIotClient 时,我在 Debug模式下发现了一个隐藏的异常: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();

它在第一次构建后无限期地阻塞,如果我切换它们,它会做同样的事情。

问题似乎出在 SdkTLSSocketFactorycom.amazonaws.http.conn.ssl中的类(class)在构造函数中执行 super() 调用时打包 ( super(sslContext, hostnameVerifier); )

我猜这可能是由于 Apache http 客户端版本与我已在程序中使用的版本冲突,但我真的不知道如何解决该问题。

有人可以帮我吗?

谢谢:)

最佳答案

又过了几个小时,我找到了解决方案。这是我的 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>

关于java - AWS IoT SDK - 构建 AWSIotData 和 AWSIotClient 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51703730/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com