Sav*_*vas 1 amazon-web-services aws-iot
我正在尝试编写一个 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();
Run Code Online (Sandbox Code Playgroud)
我知道 clientId 是什么以及如何找到我的 ID,但我无法理解 clientEndpoint。
它不是帐户的个人端点,而是事物的端点。
转到 IoT 核心 -> 管理 -> 事物,选择您的事物 -> 交互。它是 HTTPS 部分下的 URL。它应该是 xxxxxxxxxxxxxxxxxx.iot.region.amazonaws.com 的形式,其中 x 应该主要包含小写字母,可能还有一些数字。
| 归档时间: |
|
| 查看次数: |
715 次 |
| 最近记录: |