无法订阅动态主题.使用aws-iot设备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}/*"
]
}

日志/输出

错误错误:过早关闭在onclosenexttick(/Users/murtuzanalawala/Node/RioNode/Node_modules/end-of-stream/index.js:54:86(在processTicksAndRejections(internal/process/task_queues.js:75:11(连接丢失-将在128秒内尝试重新连接。。。关重新连接/重新注册连接离线

提前谢谢你的好建议。

Github问题

是的,您无法订阅动态主题,必须更改策略"arn:aws:iot:ap-south-1:453533943651:topic/${iot:Connection.Thing.ThingName}/*"至*。。for allow all device.then you can subscribe.ttopic/${iot:Connection.Thing.ThingName}这表示ThingName应该位于主题的末尾。更改为允许所有用户订阅。

最新更新