无法订阅动态主题。使用 aws-iot-device-sdk
not able to subscribe dynamic topic. using aws-iot-device-sdk
当我订阅连接阴影的动态主题时。我无法建立连接设备。没有订阅它已连接但无法接收消息负载。
代码
this.thingShadows = new awsiot.thingShadow({
keyPath: keyPath,
certPath: certPath,
caPath: caPath,
clientId: clientId, //"sdk-nodejs-" + clientId,
host: host,
debug: true,
});
this.thingShadows.subscribe(clientId + "/*");
政策
{
"Effect": "Allow",
"Action": [
"iot:Connect"
],
"Resource": [
"arn:aws:iot:ap-south-1:453533943651:client/${iot:Connection.Thing.ThingName}"
]
},
{
"Effect": "Allow",
"Action": [
"iot:Publish"
],
"Resource": [
"arn:aws:iot:us-south-1:453533943651:topic/${iot:Connection.Thing.ThingName}/*"
]
},
{
"Effect": "Allow",
"Action": [
"iot:Subscribe"
],
"Resource": [
"arn:aws:iot:us-south-1:453533943651:topicfilter/${iot:Connection.Thing.ThingName}/*"
]
},
{
"Effect": "Allow",
"Action": [
"iot:Receive"
],
"Resource": [
"arn:aws:iot:ap-south-1:453533943651:topic/${iot:Connection.Thing.ThingName}/*"
]
}
Logs/Output
error 错误:过早关闭
在 onclosenexttick (/Users/murtuzanalawala/Node/RiooNode/node_modules/end-of-stream/index.js:54:86)
在 processTicksAndRejections (internal/process/task_queues.js:75:11)
连接丢失 - 将在 128 秒后尝试重新连接...
关
reconnect/re-register
连接
离线
提前感谢您的好建议。
是的,您无法订阅动态主题,您必须更改策略 "arn:aws:iot:ap-south-1:453533943651:topic/${iot:Connection.Thing.ThingName}/* " to *..for allow all device.then you can subscribe.topic/${iot:Connection.Thing.ThingName} 这表示事物名称应该是主题的结尾。更改为允许所有您可以订阅。
当我订阅连接阴影的动态主题时。我无法建立连接设备。没有订阅它已连接但无法接收消息负载。
代码
this.thingShadows = new awsiot.thingShadow({
keyPath: keyPath,
certPath: certPath,
caPath: caPath,
clientId: clientId, //"sdk-nodejs-" + clientId,
host: host,
debug: true,
});
this.thingShadows.subscribe(clientId + "/*");
政策
{
"Effect": "Allow",
"Action": [
"iot:Connect"
],
"Resource": [
"arn:aws:iot:ap-south-1:453533943651:client/${iot:Connection.Thing.ThingName}"
]
},
{
"Effect": "Allow",
"Action": [
"iot:Publish"
],
"Resource": [
"arn:aws:iot:us-south-1:453533943651:topic/${iot:Connection.Thing.ThingName}/*"
]
},
{
"Effect": "Allow",
"Action": [
"iot:Subscribe"
],
"Resource": [
"arn:aws:iot:us-south-1:453533943651:topicfilter/${iot:Connection.Thing.ThingName}/*"
]
},
{
"Effect": "Allow",
"Action": [
"iot:Receive"
],
"Resource": [
"arn:aws:iot:ap-south-1:453533943651:topic/${iot:Connection.Thing.ThingName}/*"
]
}
Logs/Output
error 错误:过早关闭 在 onclosenexttick (/Users/murtuzanalawala/Node/RiooNode/node_modules/end-of-stream/index.js:54:86) 在 processTicksAndRejections (internal/process/task_queues.js:75:11) 连接丢失 - 将在 128 秒后尝试重新连接... 关 reconnect/re-register 连接 离线
提前感谢您的好建议。
是的,您无法订阅动态主题,您必须更改策略 "arn:aws:iot:ap-south-1:453533943651:topic/${iot:Connection.Thing.ThingName}/* " to *..for allow all device.then you can subscribe.topic/${iot:Connection.Thing.ThingName} 这表示事物名称应该是主题的结尾。更改为允许所有您可以订阅。