Cannot publish to IoT-Core using python script (Raspberry Pi)

0

Hi there,

I've been struggling trying to publish a simple "Hello world" to AWS IoT core from my pi. Whenever I run my script it always timesout at mqttClient.connect().

I connected the device which automatically generated the certification and key files. Installed AWSIoTPython in terminal.

However I installed AWSIoTPython SDK v2 with: python3 - m pip install awsiotsdk

When I unzipped the zip folder you download when connecting a new device, and then entered the "./start.sh" command it successfully connected and published and subscribed "hello world" when it ran the pubsub.py script.

The code I have I feel is verbatim the successful examples I've seen online and the credential paths are copied directly from their folder.

Not sure what else to do to troubleshoot...

Thanks,

-Zach

已提問 1 年前檢視次數 259 次
1 個回答
0

Check that you are using the same clientid for the connection and the same topics to publish and subscribe. The certificate is associated to an AWS IoT Policy which is scoped down to some specific permission, including which clientId is allowed to connect and which topics the client can publish and subscribe to.

You can find more information about IoT Policies in the documentation.

https://docs.aws.amazon.com/iot/latest/developerguide/iot-policies.html

AWS
專家
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南