esp-aws-iot
esp-aws-iot copied to clipboard
Error(-12) connecting to ac6aacx09z5rv-ats.iot.us-east- 2.amazonaws.com:8883[0m (CA-72)
I'm constantly running into this error without any clue. Could you give some hints?
@nguyentranho , can you give some more details? Especially these:
- Have you created the thing and certificate and attached appropriate policy?
- Have you verified that everything works fine with other MQTT clients (say mosquitto) or direct AWS IoT HTTP APIs from a host machine in the same network?
- Do you always see this error or is it intermittent?
Hi, I have fixed it with following policy. I'm still confused about its syntax. I was trying to explicitly set the filter to "topic/esp32/sub" but it always replies with -12 error { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iot:*", "Resource": "arn:aws:iot:us-east-2:438468228341:*" } ] }
@nguyentranho , you can use wildcards in your resources, but if you want the policy to be more restrictive, for Publish and Receive, the Resource is in this format: "arn:aws:iot:*:*:topic/<your-topic>"
. For subscribe, it is "arn:aws:iot:*:*:topicfilter/<your-topic>"
, and for connect, it is "arn:aws:iot:*:*:client/<client-id>"
I had the similar issue, I solved by creating a policy and properly editing the resources in connect, publish and subscribe.