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": "" } ] }

已提问 2 年前88 查看次数
没有答案

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则