首先,查找此文档,也许它可以帮助您:
https://github.com/aws/aws-iot-device-sdk-js
当您将某些内容发布到 thingShadow 并且状态被接受时,您可以在频道“$aws/things//shadow/get/accepted”中订阅它。
要订阅此频道,您可以使用设备中的 subscribe 方法。
var AWS = require('aws-sdk');
var device = awsIot.device({
region: AWS.config.region,
host:AWSConfiguration.host,
clientId: clientId,
protocol: 'wss',
maximumReconnectTimeMs: 8000,
debug: true,
acessKeyId: '',
secretKey: '',
sessionToken: ''
});
device.subscribe('$aws/things/<thingName>/shadow/get/accepted');
如果您感到困惑或需要有关凭据的信息,请查看以下示例:
https://github.com/aws/aws-iot-device-sdk-js/blob/fd0807e20a0d79c721cfb3b85622392f0c65e7e1/examples/browser/mqtt-explorer/index.js
配置文件在同一个文档中。
希望能帮助到你。