Is IoT Python SDK broken with Raspberry Pi?

0

I'm following the below tutorial step by step in order to setup a Raspberry Pi for a IoT project at home.

https://docs.aws.amazon.com/iot/latest/developerguide/connecting-to-existing-device.html

I've gone over the tutorial multiple times and am quite sure I have setup the certs / policy correctly for the Thing on the AWS IoT website.

However, when I attempt to run the pubsub.py demo I get the error:

Traceback (most recent call last): File "/home/pi/aws-iot-device-sdk-python-v2/samples/pubsub.py", line 113, in <module> mqtt_connection = mqtt_connection_builder.mtls_from_path( File "/home/pi/.local/lib/python3.9/site-packages/awsiot/mqtt_connection_builder.py", line 231, in mtls_from_path return _builder(tls_ctx_options, **kwargs) File "/home/pi/.local/lib/python3.9/site-packages/awsiot/mqtt_connection_builder.py", line 189, in _builder tls_ctx = awscrt.io.ClientTlsContext(tls_ctx_options) File "/home/pi/.local/lib/python3.9/site-packages/awscrt/io.py", line 424, in init self._binding = _awscrt.client_tls_ctx_new( RuntimeError: 1033 (AWS_IO_TLS_CTX_ERROR): Failed to create tls context

Similarly, when I attempt to run the shadow.py demo I get the same error.

All I am trying to do in this project is tell Alexa to turn on a device and have it toggle a GPIO pin on and off. Super simple, but it seems like the Python SDK is broken at the moment. At least, maybe the latest version and for the Raspberry Pi.

已提問 2 年前檢視次數 801 次
1 個回答
1
已接受的答案

I've tried to reproduce the issue on my Raspberry Pi 4. The tutorial works as expected on my environment with Python 3.7.3, awscrt 0.12.1 and awsiotsdk 1.7.1.

pi@raspberrypi:~/aws-iot-device-sdk-python-v2 $ pip3 show awscrt
Name: awscrt
Version: 0.12.1
...
pi@raspberrypi:~/aws-iot-device-sdk-python-v2 $ pip3 show awsiotsdk
Name: awsiotsdk
Version: 1.7.1
...

Also, as I see from the error message you shared, you're testing on Python3.9, so I downloaded and installed the Python3.9 to simulate your environment. Again, the tutorial works as expected. I'm sharing my test outputs to help your troubleshooting. PS: I've masked some identifiers with ** characters.


pi@raspberrypi:~/aws-iot-device-sdk-python-v2/samples $ python3.9 --version
Python 3.9.9
pi@raspberrypi:~/aws-iot-device-sdk-python-v2/samples $ pip3.9 freeze
awscrt==0.12.1
awsiotsdk==1.7.1
pi@raspberrypi:~/aws-iot-device-sdk-python-v2/samples $ python3.9 pubsub.py --topic topic_1 --root-ca ~/certs/AmazonRootCA1.pem --cert ~/certs/**-certificate.pem.crt --key ~/certs/**-private.pem.key --endpoint **-ats.iot.eu-west-1.amazonaws.com
Connecting to **-ats.iot.eu-west-1.amazonaws.com with client ID 'test-**'...
Connected!
Subscribing to topic 'topic_1'...
Subscribed with QoS.AT_LEAST_ONCE
Sending 10 message(s)
Publishing message to topic 'topic_1': Hello World! [1]
Received message from topic 'topic_1': b'"Hello World! [1]"'
Publishing message to topic 'topic_1': Hello World! [2]
Received message from topic 'topic_1': b'"Hello World! [2]"'

So, here are some action points that can help troubleshooting the issue:

  • Can you check if you have, at least, those versions of packages by running pip3 show <package-name> commands?
  • Can you check if you're providing correct certificates to the python3 pubsub.py command? Please notice the match between certificate file extensions and the parameters.
FileFile path
Root CA certificate~/certs/Amazon-root-CA-1.pem
Device certificate~/certs/device.pem.crt
Private key~/certs/private.pem.key
AWS
已回答 2 年前
profile picture
專家
已審閱 5 天前

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

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

回答問題指南