Hi @AJ Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.
retry policy is not supported in Python
Even though the Python SDK does not support Exponential back-off with jitter or Custom Retry, there is a retry policy configuration that can be passed through connection_retry_interval
parameter of the IoTHubDeviceClient class. The default value for this is 10 seconds. We can change this to modify the attempts to re-establish a dropped connection.
Please note that this setting does not effect the time out of the iot_hub_device_client.send_message()
method. I do not see an option to override the time out setting for this method. It would not be advised to change this setting to 2 seconds as this would cause false exceptions in the cases where the device might still be connected but it takes longer time to process the message delivery due to poor network.
One possible approach to consider for overcoming the issue is by creating an async method definition where you call the await iot_hub_device_client.send_message()
and calling this method from a different line of code without using the await keyword. See if this helps. If you don't see a change in behavior of the code execution, consider using threads and have a thread work on queuing the messages while the other thread handles message delivery.
Hope this helps. Please let us know if you need any additional assistance with this.