Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeviceNotFoundException results in InvalidErrorCode (404103) #3442

Open
pregress opened this issue Mar 14, 2024 · 2 comments
Open

DeviceNotFoundException results in InvalidErrorCode (404103) #3442

pregress opened this issue Mar 14, 2024 · 2 comments
Labels
bug Something isn't working. fix-checked-in Fix checked into main or preview, but not yet released.

Comments

@pregress
Copy link

pregress commented Mar 14, 2024

Context

  • OS, version, SKU and CPU architecture used: Windows 11 Desktop x64 OS build: 22621.3155
  • Application's .NET Target Framework : .NET Sdk: 8.0.101
  • Device: Laptop
  • SDK version used: Azure.Identity 1.10.4, Microsoft.Azure.Devices.Client 1.42.2n Microsoft.Azure.Devices 1.39.1

Description of the issue

https://github.com/Azure/azure-iot-sdk-csharp/blob/main/iothub/service/src/Common/Exceptions/ErrorCode.cs should contain a value for 404103 DeviceOffline

When invoking a direct method on an offline device. A device not found is thrown. OK
The exception.ErrorCode is InvalidErrorCode.

Whilst the json contains: errorCode: 404103

{"Message":"{\"errorCode\":404103,\"trackingId\":\"aa761f96e9174d0e849c96a8b2e10a8c-TimeStamp:03/14/2024 09:54:49\",\"message\":\"The operation failed because the requested device isn't online or hasn't registered the direct method callback. To learn more, see https://aka.ms/iothub404103\",\"info\":{\"timeout\":\"00:00:00\"},\"timestampUtc\":\"2024-03-14T09:54:49.6536567Z\"}","ExceptionMessage":""}

Code sample exhibiting the issue

try
{
   var credential = new AzureCliCredential();
   var serviceClient = ServiceClient.Create($"redacted-hostname.azure-devices.net", credential);
   await serviceClient.InvokeDeviceMethodAsync("YourDevice",  new CloudToDeviceMethod("YourDirectMethod", TimeSpan.FromSeconds(10)));
}
catch (DeviceNotFoundException ex)
{   
    Console.WriteLine("Offline? " +  ex.Code);
}

Console log of the issue

Offline? InvalidErrorCode

@pregress pregress added the bug Something isn't working. label Mar 14, 2024
@timtay-microsoft timtay-microsoft added the fix-checked-in Fix checked into main or preview, but not yet released. label Apr 9, 2024
@pregress
Copy link
Author

Merged in: #3450

@Alexolo
Copy link

Alexolo commented Jun 7, 2024

I'm also interested in this, an correct me if im wrong, but merge #3450, only solves it into v2, not v1 nugets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. fix-checked-in Fix checked into main or preview, but not yet released.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants