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

posta 10 mesi fa1322 visualizzazioni
2 Risposte
1
profile pictureAWS
ESPERTO
Greg_B
con risposta 10 mesi fa
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
con risposta 10 mesi fa
  • 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

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande