Node.js 无法订阅动态主题。使用aws物联网设备sdk
当我订阅连接阴影的动态主题时。我无法连接设备。没有订阅,它已连接,但无法接收消息负载。 代码 政策Node.js 无法订阅动态主题。使用aws物联网设备sdk,node.js,aws-iot,aws-iot-core,Node.js,Aws Iot,Aws Iot Core,当我订阅连接阴影的动态主题时。我无法连接设备。没有订阅,它已连接,但无法接收消息负载。 代码 政策 { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:ap-south-1:453533943651:client/${iot:Connection.Thi
{
"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/RiooNode/Node_modules/end of stream/index.js:54:86)
在处理和拒绝时(内部/process/task_queues.js:75:11)
连接丢失-将在128秒内尝试重新连接。。。
关闭
重新连接/重新注册
连接
离线
提前谢谢你的好建议
是的,您无法订阅动态主题您必须将策略“arn:aws:iot:ap-south-1:453533943651:topic/${iot:Connection.Thing.ThingName}/*”更改为*。以允许所有设备。然后您可以订阅。topic/${iot:Connection.Thing.ThingName}。这表示ThingName应位于主题末尾。更改以允许您能够订阅的所有内容
{
"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}/*"
]
}