azureazure-iot-hubazure-iot-sdkazure-iot-dps

Azure sdk receiving different error messages while trying to connect to IotHub when device is disabled


I am using Azure Java SDK to connect to two different IotHubs using X509 certificate. I want to receive the identical error messages when the devices are disabled in both the IotHubs.

However, I am getting two different messages.

e.g.

I am trying to connect device1 to IotHub1 using the X509 cert used to register the device in IotHub1, where device1 is disabled in the IotHub,I am getting following error : 404001 (Device is Disabled).

Now let's say I am trying to connect to device2 to IotHub2 using X509 cert used to register the device in IotHub2, where device 2 is disabled. I am getting following error code: 401002(UnAuthorized) even though I am using a valid cert.

Is there any setting in IotHub that might be throwing the unauthorized error rather than disabled error and if we can update it to send disabled error rather than unauthorized error in this case?

Both of these IotHubs are linked to one Device Provisioning Service(one enrollment group with X509 intermediate certificate set as attestation mechanism).


Solution

  • I suspect that one of your IoT hubs has been migrated to GatewayV2. It is possible that you will receive different error codes from a V2 gateway versus a V1 gateway. You can check this by going to the Azure Portal and opening the overview blade for your IoT hub. From there click on the 'JSON view' link in the top right corner. In the JSON, look for properties.features. If your IoT hub is on the V2 gateway, you will see GWV2 in that string. If it is not, then there will be no mention of the gateway version. Check both hubs to see if one is on V2 and the other is not. Be aware, all IoT hubs will be migrated to V2 eventually.