- 最新
- 投票最多
- 评论最多
【以下的回答经过翻译处理】 我正在按照以下教程逐步设置树莓派,以便在家中进行物联网项目。 https://docs.aws.amazon.com/iot/latest/developerguide/connecting-to-existing-device.html 我已经多次阅读了教程,并且非常确定我在AWS IoT网站上为物联网设备正确设置了证书和策略。 然而,当我尝试运行pubsub.py示例时,出现了错误: 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 同样地,当我尝试运行shadow.py示例时,出现了相同的错误。 在这个项目中,我只是想告诉Alexa打开一个设备,并让它切换GPIO引脚的开关状态。非常简单,但目前似乎Python SDK出现了问题。至少,可能是最新版本和树莓派的兼容性问题。
我尝试在我的树莓派4上复现这个问题。在我的环境中,使用Python 3.7.3、awscrt 0.12.1和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
...
另外,根据您分享的错误信息,我看到您正在使用Python3.9进行测试,所以我下载并安装了Python3.9来模拟您的环境。同样地,教程按预期工作。我将分享我的测试输出以帮助您进行故障排除。PS:我用字符掩盖了一些标识符。
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]"'
以下是一些可以帮助进行故障排除的操作步骤:
• 您可以通过运行"pip3 show <package-name>"命令来检查您是否至少拥有这些软件包的版本。
• 您可以检查是否正确地向python3 pubsub.py命令提供了正确的证书。请注意证书文件扩展名与参数之间的匹配。
File File path
Root CA certificate ~/certs/Amazon-root-CA-1.pem
Device certificate ~/certs/device.pem.crt
Private key ~/certs/private.pem.key
相关内容
- AWS 官方已更新 2 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 3 年前
- AWS 官方已更新 10 个月前