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달 전1322회 조회
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

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인