By using AWS re:Post, you agree to the Terms of Use

IoT thing auto reconnect using python SDK

0

Using AWS Python SDK, I am communicating with the IoT thing which has a sensor device connected. I am utilizing the MQTT for sending the message to IoT and writing the sensor data to IoT shadow. In the connection code, I have configured the configureAutoReconnectBackoffTime to restablish the connection automatically.

whenever network goes, the callback return "REQEUST TIME OUT". When the network comes back, it automatcilly writes the data to IoT Shadow. But sometimes, it takes more time to reestablish the connection. Many times the network is up and I am getting the response from ping. But it takes more time to reconnect. I increased the maxReconnectQuietTimeSecond time in configureAutoReconnectBackoffTime, still I am getting the same error.

I am using the below lines in the IoT connection code.

    Iot_connection = AWSIoTMQTTShadowClient(clientId)
    Iot_connection.configureEndpoint(host, 8883)
    Iot_connection.configureCredentials("{}AmazonRootCA1.pem".format(certPath), "{}iot_private.key".format(certPath), "{}iot_cert.crt".format(certPath))
    Iot_connection.configureAutoReconnectBackoffTime(1, 6, 5)
    Iot_connection.configureConnectDisconnectTimeout(5)
  • Hi, have you tried connecting without invoking configureAutoReconnectBackoffTime and configureConnectDisconnectTimeout to see if it works? This would be helpful to troubleshoot whether you have either issues with your certificates or with the IoT Thing Policy associated with your certificates. Also, while you're at it, please share the IoT Thing Policy attached to your certificates so we can rule out any other required configuration there.

  • David, I am connecting without invoking the configureAutoReconnectBackoffTime and configureConnectDisconnectTimeout. In the meantime, please find the policy attached to the IoT

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

No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions