Reputation: 81
azure-iot-device : 2.14.0 azure-iot-hub : 2.6.1 asyncio : 3.4.3 Python Version : 3.10.12 Azure IoTHub Details: Tier: S1
Description of Issue: This issue is on Linux/Ubuntu 22.04 LTS It is working just fine on Windows 11 I have developed a Python script using the Azure IoT SDK to connect 670 devices to Azure IoT Hub. The script is designed to connect each device asynchronously, update the device twin, and send telemetry data in parallel.
However, I am facing a connectivity limitation when running the script for all 670 devices simultaneously: After 337 devices successfully connect, update their twins, and start sending telemetry, the remaining devices are unable to establish a connection. Logs indicate a new connection error for devices beyond the initial 337 connections, with the following details:
pipeline_stages_mqtt.py:83 - MQTTTransportStage(ConnectOperation): Connection watchdog expired. Cancelling op mqtt_transport.py:441 - disconnecting MQTT client async_adapter.py:72 - Callback completed with error Transport timeout on connection operation async_adapter.py:73 - ['azure.iot.device.common.pipeline.pipeline_exceptions.OperationTimeout: Transport timeout on connection operation\n'] mqtt_transport.py:150 - Creating client for connecting using MQTT over TCP
In the exception, the error message received is: Error: Could not complete operation before timeout.
Interestingly, when I divide the workload into two batches of 335 devices each, running them in separate instances of a python script from the same IP address, all connections are successful, and each device updates its twin and sends telemetry as expected.
Upvotes: 0
Views: 125
Reputation: 3639
As per this document, there is no specific limit on the number of simultaneously connected devices, but there is a limit on the number of new connections allowed per second, based on the selected tier and units.
For the Free tier and S1, the number of new connections is limited to 100 per second, or 12 connections per second per unit.
To meet your requirements of 670 devices , you need the S3 tier, as it can handle up to 6,000 new connections per second per unit. The maximum number of concurrently connected device streams is 50 for all tiers.
I referred to this doc for running up to 1,000 devices per job .
async def device_twin_job(job_id, device_id, execution_time):
print ( "" )
print ( "Scheduling job " + str(job_id) )
job_request = JobRequest()
job_request.job_id = job_id
job_request.type = "scheduleUpdateTwin"
job_request.start_time = datetime.datetime.utcnow().isoformat()
job_request.update_twin = Twin(etag="*", properties=TwinProperties(desired=UPDATE_PATCH))
job_request.max_execution_time_in_seconds = execution_time
job_request.query_condition = "DeviceId in ['{}']".format(device_id)
Output:
Upvotes: 0