【问题标题】:How can I find my personal endpoint in AWS IoT?如何在 AWS IoT 中找到我的个人终端节点?
【发布时间】:2019-12-27 11:34:02
【问题描述】:

我正在尝试编写一个 Java 应用程序,它的行为就像一个事物,在 AWS 中发布数据。文档有这个代码示例:

String clientEndpoint = "<prefix>.iot.<region>.amazonaws.com";       // replace <prefix> and <region> with your own
String clientId = "<unique client id>";                              // replace with your own client ID. Use unique client IDs for concurrent connections.
String certificateFile = "<certificate file>";                       // X.509 based certificate file
String privateKeyFile = "<private key file>";                        // PKCS#1 or PKCS#8 PEM encoded private key file

// SampleUtil.java and its dependency PrivateKeyReader.java can be copied from the sample source code.
// Alternatively, you could load key store directly from a file - see the example included in this README.
KeyStorePasswordPair pair = SampleUtil.getKeyStorePasswordPair(certificateFile, privateKeyFile);
AWSIotMqttClient client = new AWSIotMqttClient(clientEndpoint, clientId, pair.keyStore, pair.keyPassword);

// optional parameters can be set before connect()
client.connect();

我知道 clientId 是什么以及如何找到我的 ID,但我无法理解 clientEndpoint 中的内容。

【问题讨论】:

    标签: amazon-web-services aws-iot


    【解决方案1】:

    不是帐户的个人端点,而是事物的端点。

    转到 IoT Core -> 管理 -> 事物,选择您的事物 -> 交互。 它是 HTTPS 部分下的 URL。它应该是 xxxxxxxxxxxxxxxxx.iot.region.amazonaws.com 的形式,其中 x 应该主要包含小写字母,可能还有一些数字。

    【讨论】:

    • 这也可以在 IoT Core 的 Settings 部分找到。只需单击一下即可到达那里:)
    • 哦,没想到它可以在设置中。如果你从那里看到它,它也说它对所有事物都是一样的。很高兴知道!
    【解决方案2】:

    拨打DescribeEndpoint API

    在 Java 中,这将是:

            AWSIot awsIotClient = AWSIotClientBuilder.defaultClient();
            DescribeEndpointRequest request = new DescribeEndpointRequest().withEndpointType("iot:Data");
            DescribeEndpointResult result = awsIotClient.describeEndpoint(request);
            String endpoint = result.getEndpointAddress();
    

    【讨论】:

      猜你喜欢
      • 2019-01-20
      • 1970-01-01
      • 1970-01-01
      • 2021-04-02
      • 1970-01-01
      • 2012-03-30
      • 2017-10-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多