【问题标题】:AWS IoT SDK - Exception while building AWSIotData and AWSIotClientAWS IoT SDK - 构建 AWSIotData 和 AWSIotClient 时出现异常
【发布时间】:2019-01-13 04:23:51
【问题描述】:

我目前正在使用适用于 java (v1.11.380) 的 aws-iot-sdk,并且在构建 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();

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

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

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

谁能帮我解决这个问题?

谢谢你:)

【问题讨论】:

    标签: java apache exception aws-sdk aws-iot


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2017-02-27
      • 2017-10-29
      • 1970-01-01
      • 2018-11-21
      • 2022-07-07
      • 2021-06-18
      • 2020-01-15
      • 2018-05-04
      • 2018-02-27
      相关资源
      最近更新 更多