question

bcb44-4548 avatar image
0 Votes"
bcb44-4548 asked bcb44-4548 commented

List of Error Codes for IoTHub File Upload API

Hello,

I'm uploading files to Azure using the c# sdk. When I run the DeviceClient.CompleteFileUploadAsync() method, I sometimes get a System.ArgumentException that has a couple of different of error codes and messages. The main ones I've seen are "Bad Request", "Expired correlationID", and "Invalid correlation ID".
Is there a way for me to see all of the error messages and codes for the API?

Also, I handle different messages in different ways. Which are more consistent, the error codes or the error messages? My worry is because these aren't part of the sdk and I'm catching them based on the actual text based error message, they're going to update and my app will break. Any advice on this?

Here's my code
try {
await deviceClient.CompleteFileUploadAsync(createUploadInfo(corrId), cancelToken);
}
catch (ArgumentException ex) {
if (ex.Message.Contains("Bad Request")) {
//do action
}
else if (ex.Message.Contains("Expired correlation ID")) {
//do another action
}
else if (ex.Message.Contains("Invalid correlation ID")) {
//do another action
}
//alert user of break
}`

azure-iot-hubazure-iot-sdk
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

First thing, you could get these exceptions:

  • ObjectDisposedException - if the client is disposed

  • OperationCancelledException - if the cancellation token parameter has been signaled

Then, depending on the HTTP status code returned from the service, you could see (some of these are unlikely or even nonsense given this specific operation):

  • DeviceNotFoundException

  • ArgumentException - bad request (400) from service. See exception message for details.

  • UnauthorizedException - if you see this, you'd have other problems using the device client too, so unlikely to see.

  • QuotaExceededException - a specific operation has failed due to exceeded quota; wait a bit and try again.

  • DeviceMessageLockLostException - doesn't seem relevant.

  • MessageTooLargeException - doesn't seem relevant.

  • ServerErrorException - the server failed to process for some reason; try again.

  • ServerBusyException - the server failed to process because it is overloaded; try again.

  • IotHubThrottledException - the hub related to the request is being throttled due to too much activity; wait a bit and try again.

I agree, switching on an exception based on the message text is undesirable. I will check with our service team to see if specific error codes can be returned, or if all we have to go on is the error message.



2 Votes 2 ·

There are definitely codes that get returned when I get these errors so I'm pretty sure they exist. I'll try to recreate some of the errors and I'll post the codes I can find. Thank you!

0 Votes 0 ·

Hello @bcb44-4548 We have escalated this to our team. Will get back to you soon on this case.

1 Vote 1 ·

1 Answer

drwill-ms avatar image
2 Votes"
drwill-ms answered bcb44-4548 commented

It looks like there is a bug in the service right now, where any malformed correlation Id will result in an HTTP status code of 500, which the SDK will turn into a ServerErrorException with a response body and exception message of:

{ "Message": "{\"errorCode\":500001,\"trackingId\":\"b18e47205f024726923046c53de3067d-G:0-TimeStamp:08/02/2021 18:27:03\",\"message\":\"InternalServerError\",\"timestampUtc\":\"2021-08-02T18:27:03.2607187Z\"}", "ExceptionMessage": "" }

My contact on the service team will get a fix in, but I don't have an ETA yet.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Ok thank you for the heads up!

0 Votes 0 ·