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ビュー
回答なし

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ