- Newest
- Most votes
- Most comments
Hi. In your current code, your QoS sending loop time is almost entirely governed by your time.sleep(0.1)
call.
That sample is using the publish() method and it's a blocking call for QoS 1. It will wait for the PUBACK from AWS IoT Core before the call returns: https://github.com/aws/aws-iot-device-sdk-python/blob/0b195b82349e2d5b9715d4880da747bfbaaa1437/AWSIoTPythonSDK/core/protocol/mqtt_core.py#L267-L273
You would likely instead prefer the publishAsync() method. This will not block, and instead allow you to have multiple QoS 1 transactions in flight at once. Please see this sample: https://github.com/aws/aws-iot-device-sdk-python/blob/master/samples/basicPubSub/basicPubSubAsync.py
If you aren't already, you should use the AWS IoT Core endpoint that is in the nearest region, to minimize the round trip time. And if you really want to maximize the throughput, you should remove the time.sleep()
altogether.
Note that IoT Core has a limit of 100 publishes per second per client connection. And a maximum of 100 inbound QoS 1 transactions can be in flight at any one time. https://docs.aws.amazon.com/general/latest/gr/iot-core.html#message-broker-limits
Finally I would recommend you instead use the V2 SDK: https://github.com/aws/aws-iot-device-sdk-python-v2. From the V1 README:
A new AWS IoT Device SDK is now available. It is a complete rework, built to improve reliability, performance, and security. We invite your feedback!
This SDK will no longer receive feature updates, but will receive security updates.
Relevant content
- Accepted Answerasked 2 years ago
- Accepted Answerasked 3 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated a year ago
Thank you for your reply. I haven't tried V2 SDK yet but publishAsync() solved the problem. Really appreicate it!.