AWS IoT Core MQTT Connection Timeout Error

0

I am working on a project that involves connecting an MQTT client to AWS IoT Core. I am using the AWSIoTPythonSDK and paho.mqtt.client libraries in Python. The client is intended to subscribe to two topics and publish the received data to AWS IoT Core.

However, I am encountering a "AWSIoTPythonSDK.exception.AWSIoTExceptions.connectTimeoutException" error after a few seconds of successful operation. The client connects to the MQTT broker (IP: 140.114.89.210, Port: 1883) and subscribes to the topics "wt/generator" and "wt/ws3."

The code successfully connects to the broker and receives data from both topics. However, after a few seconds, it throws the mentioned "connectTimeoutException." I've checked my network settings, security groups, and IAM role permissions, and they seem to be correctly configured. The AWS IoT Core endpoint and credentials are also accurate.

Could someone help me identify the possible reasons for this timeout exception and suggest potential solutions? Are there any additional troubleshooting steps I can take to resolve this issue?

Any guidance or insights would be greatly appreciated. Thank you!

Here's the relevant part of my code:

# [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()

質問済み 10ヶ月前1320ビュー
2回答
1
profile pictureAWS
エキスパート
Greg_B
回答済み 10ヶ月前
0

Hi, Check a few things:

  • Do you have an active certificate attached to your "thing"?
  • Do you have a policy attached to the certificates?
  • What does your policy look like? Does it allow the correct permissions to the correct topics?

Cheers! Oscar.

AWS
回答済み 10ヶ月前
  • Hello Sir, Thank You so much for your response,

    I want to mention some points about this suggestion

    All the certificates which are attached in the code are active.

    I also have attached the policy which looks something like this:

    { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iot:", "Resource": "" } ] }

    I think this policy will allow all the permissions required for both the topics

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ