aws/aws-iot-device-sdk-python-v2

429 message:'TOO_MANY_REQUESTS' - RuntimeError: 5131 (AWS_ERROR_MQTT_NOT_CONNECTED)

1960pghpirates opened this issue · 2 comments

Describe the bug

MQTT connection to the IoT Core endpoint is not stable after upgrading from V1 to V2 of the SDK. Client on Raspberry Pi Zero drops the MQTT connection within a week of starting to run. The client encounters a fatal error and stops sending updates.

Expected Behavior

Connection to IoT Core to remain stable as it did for V1 of the SDK before I upgraded to V2.

Current Behavior

Client ran for about a week before this error occurred:

........
Finished updating reported shadow value to '{'CO2': '605', 'temperature': '21.51', 'humidity': '38.16', 'VOC': '149'}'.
Finished updating reported shadow value to '{'CO2': '605', 'temperature': '21.52', 'humidity': '38.18', 'VOC': '149'}'.
Exiting sample: Update request was rejected. code:429 message:'TOO_MANY_REQUESTS'
Disconnecting...
Disconnected.
CO2: 604 ppm
Temperature: 22.5 C
Humidity: 38.6 %RH
VOC Index: 146

Changed local shadow value to '{'CO2': '604', 'temperature': '21.46', 'humidity': '38.58', 'VOC': '146'}'.
Updating reported shadow value to '{'CO2': '604', 'temperature': '21.46', 'humidity': '38.58', 'VOC': '146'}'...
value = {'CO2': '604', 'temperature': '21.46', 'humidity': '38.58', 'VOC': '146'}
Failed to publish update request.
Exiting sample due to exception.
Traceback (most recent call last):
File "SGP40_SDK2.py", line 229, in on_publish_update_shadow
future.result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 425, in result
return self.__get_result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/home/pi/.local/lib/python3.7/site-packages/awscrt/mqtt.py", line 684, in publish
packet_id = _awscrt.mqtt_client_connection_publish(self._binding, topic, payload, qos.value, retain, puback)
RuntimeError: 5131 (AWS_ERROR_MQTT_NOT_CONNECTED): The requested operation is invalid as the connection is not open.

Reproduction Steps

I have opened several GitHub issues for this problem already and taken the suggested troubleshooting steps. I provided a code sample as well. The error message of Too Many Requests is new. I am hoping it provides some insight into the problem.

(#257)
(#272)

Possible Solution

Limit the number of shadows sent to the MQTT queue before they are processed.

Additional Information/Context

No response

SDK version used

AWS IoT Python SDK v2

Environment details (OS name and version, etc.)

Raspberry Pi Zero

Are you still using QOS 0 when you get this message? Also can you get more detailed trace logs from when this is happening? It's hard to tell what exactly might be happening and how long you where offline when this happened.

Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.