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

asked a year ago246 views
1 Answer
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
EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions