AWS IoT Core MQTT 连接超时错误

问题描述 投票:0回答:0

我正在开发一个涉及将 MQTT 客户端连接到 AWS IoT Core 的项目。我正在 Python 中使用 AWSIoTPythonSDK 和 paho.mqtt.client 库。客户端打算订阅两个主题并将接收到的数据发布到 AWS IoT Core。

但是,在成功操作几秒钟后,我遇到了“AWSIoTPythonSDK.exception.AWSIoTExceptions.connectTimeoutException”错误。客户端连接到MQTT代理(IP:140.114.89.210,端口:1883)并订阅主题“wt/generator”和“wt/ws3”

代码成功连接到代理并接收来自两个主题的数据。然而,几秒钟后,它抛出提到的“connectTimeoutException”。我已检查我的网络设置、安全组和 IAM 角色权限,它们似乎配置正确。 AWS IoT Core 端点和凭证也准确。

有人可以帮助我确定此超时异常的可能原因并提出潜在的解决方案吗?我可以采取任何其他故障排除步骤来解决此问题吗?

任何指导或见解将不胜感激。谢谢!

这是我的代码的相关部分:

# [Include code snippet from data_fetcher.py where the MQTT client is initialized and on_connect, on_message functions are defined]

mqttServer = "140.114.89.210"
generator_topic = "wt/generator"
ws3_topic = "wt/ws3"

# AWS IoT Core endpoint (replace with your actual endpoint)
IOT_CORE_ENDPOINT = "xxxxxxxxxxxxxx-ats.iot.us-east-1.amazonaws.com"
# [Other relevant configurations]

client.connect(mqttServer, 1883, 120)
client.loop_forever()
python amazon-web-services mqtt iot aws-iot-core
© www.soinside.com 2019 - 2024. All rights reserved.