The Azure IoT C SDK supports multiplexing - the ability to have multiple device identities sharing the same underlying TLS connection. There are many limitations in its support, however. Before using multiplexing you need to carefully understand these.
If you are creating a gateway device, Azure IoT Edge is highly recommend over using this SDK to multiplex leaf devices. Edge was designed from the ground up for gateway scenarios including full multiplexing support, store and forward of messages, enhanced diagnostics, module support, and more.
If you need multiplexing for a non-gateway scenario, and if your device has the required resources, using the Azure IoT Device SDK for C# is highly recommended. The C# Device SDK has a more complete feature set for multiplexing support.
The rest of this document will discuss the Azure IoT Device SDK for C (this repo's) multiplexing support.
Multiplexing is supported on the AMQP, AMQP over WebSockets, and HTTPS protocols. It is not supported on MQTT or MQTT over WebSockets.
When multiplexing over an AMQP, AMQP over WebSockets, or HTTP connection, the SDK supports:
- Sending telemetry (
IoTHubDeviceClient_LL_SendEventAsync
andIoTHubDeviceClient_SendEventAsync
) - Receiving incoming Cloud-to-Device messages (via callbacks set in
IoTHubDeviceClient_LL_SetMessageCallback
IoTHubDeviceClient_SetMessageCallback
)
When multiplexing over an AMQP or AMQP over WebSockets connection (but not HTTP), the SDK also supports
- Receiving incoming device methods (via callbacks set in
IoTHubDeviceClient_LL_SetDeviceMethodCallback
andIoTHubDeviceClient_SetDeviceMethodCallback
).
The SDK does not support any other features, such as receiving device twins, sending device twin updates, or uploading files to Azure Storage. Any additional IoT features added to the SDK will not support multiplexing.
Multiplexing only works when using device client handles (IOTHUB_DEVICE_CLIENT_HANDLE
and IOTHUB_DEVICE_CLIENT_LL_HANDLE
). Modules (IOTHUB_MODULE_CLIENT_HANDLE
and IOTHUB_MODULE_CLIENT_LL_HANDLE
) are not supported.
Samples demonstrating multiplexing are available in the device client samples folder