Engineer999
Engineer999

Reputation: 3945

I can't create an IoT Hub Device handle using IoTHubDeviceClient_LL_CreateFromDeviceAuth

I am using the Azure C SDK on Linux. I can successfully provision devices on an IoT hub through a symmetric key enrolment group and DPS using the provided prov_dev_client_sample.

Now I am using the iothub_ll_telemetry sample to send data to a provisioned device on the hub. On creating the device handle, it works fine when using this function with the device connection string :

device_ll_handle = IoTHubDeviceClient_LL_CreateFromConnectionString(connectionString, MQTT_Protocol); 

However, I would like to create the device handle this way instead within that same telemetry sample. The parameters IoT hub URI and device ID are exactly what get returned from the prov_dev_client_sample executed previously.

device_ll_handle = IoTHubDeviceClient_LL_CreateFromDeviceAuth("my-test-hub.azure-devices.net", "new-test-device", MQTT_Protocol);

I don't understand why. This fails as follows no matter what. Shouldn't this work?

Creating IoTHub Device handle
Error: Time:Wed Apr 17 13:09:39 2024 File:/home/azure-iot-sdk-c/provisioning_client/src/iothub_auth_client.c Func:iothub_device_auth_create Line:218 hsm_client_create is not a valid address
Error: Time:Wed Apr 17 13:09:39 2024 File:/home/azure-iot-sdk-c/iothub_client/src/iothub_client_authorization.c Func:IoTHubClient_Auth_CreateFromDeviceAuth Line:184 Failed allocating IOTHUB_AUTHORIZATION_DATA
Error: Time:Wed Apr 17 13:09:39 2024 File:/home/azure-iot-sdk-c/iothub_client/src/iothub_client_core_ll.c Func:initialize_iothub_client Line:875 Failed create authorization module
Error: Time:Wed Apr 17 13:09:39 2024 File:/home/azure-iot-sdk-c/iothub_client/src/iothub_client_core_ll.c Func:IoTHubClientCore_LL_CreateFromDeviceAuth Line:1324 initialize iothub client
Failure creating IotHub device. Hint: Check your connection string.
Press any key to continue

Upvotes: 0

Views: 150

Answers (0)

Related Questions