4

AWSIoTPythonSDK.exception.AWSIoTExceptions.connectTimeoutException

I'm getting this exception after running the sample python code on my machine.

Referred to the github exmaple. https://github.com/aws/aws-iot-device-sdk-python/issues/223

I tried node and python both the version of aws iot connection. Still unsuccesful

from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient

myMQTTClient = AWSIoTMQTTClient("random")


myMQTTClient.configureEndpoint("<sample>-ats.iot.ap-south-1.amazonaws.com", 8883)


myMQTTClient.configureCredentials("C:\\Users\\preetham\\Desktop\\awsiot\\root-CA.crt", "C:\\Users\\preetham\\Desktop\\awsiot\\SWM-Preetham.private.key", "C:\\Users\\preetham\\Desktop\\awsiot\\SWM-Preetham.cert.pem")


myMQTTClient.configureOfflinePublishQueueing(-1)  
myMQTTClient.configureDrainingFrequency(2)  
myMQTTClient.configureConnectDisconnectTimeout(10) 
myMQTTClient.configureMQTTOperationTimeout(5)  

myMQTTClient.connect()

while 1:
    myMQTTClient.publish("topic", "myPayload", 1)

can some one help me why this is happening? We didn't face this anytime before. Little surprised on this.

XLR8 Robotics
  • 41
  • 1
  • 3

1 Answers1

6

The sample created automatically associated a policy with some very specific restrictions, which actually blocked even the ThingShadowEcho sample to connect, by changing the policy to a very broad policy might be risky, but will get this exception solved. First, go to aws console, find Secure/Policies, locate the specific policy for "Random", in that "Random-policy" choose edit policy document, put the following in there, and try again.

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

JCQian
  • 819
  • 6
  • 10