Azure / azure-iot-sdk-csharp

A C# SDK for connecting devices to Microsoft Azure IoT services
Other
466 stars 493 forks source link

DeviceClient.UpdateReportedPropertiesAsync throws exceptions #420

Closed dmytro-gokun closed 6 years ago

dmytro-gokun commented 6 years ago

Windows x64 (Azure), Microsoft.Azure.Devices.Client, 1.7.0

Calls to DeviceClient.UpdateReportedPropertiesAsync fail with the following exceptions:

1) System.AggregateException: One or more errors occurred. ---> Microsoft.Azure.Devices.Client.Exceptions.IotHubException: {"errorCode":409002,"trackingId":"aca6799496ea44a797428815953899c6-G:15-TimeStamp:03/22/2018 10:27:31","message":"Conflict","timestampUtc":"2018-03-22T10:27:31.6949816Z"} at Microsoft.Azure.Devices.Client.DeviceClient.<>c.<ApplyTimeout>b__74_2(Task t) at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Keatech.Thinkrace.Gateway.Handlers.Receiver.<OnMessageAsync>d__10.MoveNext() in D:\users\Dmytro\work\Keatech\git\Keatech.Thinkrace.Gateway\Handlers\Receiver.cs:line 110 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at Keatech.Thinkrace.Gateway.Handlers.Receiver.OnMessage(IChannelHandlerContext context, DeviceMessage message) in D:\users\Dmytro\work\Keatech\git\Keatech.Thinkrace.Gateway\Handlers\Receiver.cs:line 89 at DotNetty.Transport.Channels.AbstractChannelHandlerContext.InvokeChannelRead(Object msg) ---> (Inner Exception #0) Microsoft.Azure.Devices.Client.Exceptions.IotHubException: {"errorCode":409002,"trackingId":"aca6799496ea44a797428815953899c6-G:15-TimeStamp:03/22/2018 10:27:31","message":"Conflict","timestampUtc":"2018-03-22T10:27:31.6949816Z"} at Microsoft.Azure.Devices.Client.DeviceClient.<>c.<ApplyTimeout>b__74_2(Task t) at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Keatech.Thinkrace.Gateway.Handlers.Receiver.<OnMessageAsync>d__10.MoveNext() in D:\users\Dmytro\work\Keatech\git\Keatech.Thinkrace.Gateway\Handlers\Receiver.cs:line 110<---

2) System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Service rejected the message with status: 404 at Microsoft.Azure.Devices.Client.DeviceClient.<>c.<ApplyTimeout>b__74_2(Task t) at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Keatech.Thinkrace.Gateway.Handlers.Receiver.<OnMessageAsync>d__10.MoveNext() in D:\users\Dmytro\work\Keatech\git\Keatech.Thinkrace.Gateway\Handlers\Receiver.cs:line 110 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at Keatech.Thinkrace.Gateway.Handlers.Receiver.OnMessage(IChannelHandlerContext context, DeviceMessage message) in D:\users\Dmytro\work\Keatech\git\Keatech.Thinkrace.Gateway\Handlers\Receiver.cs:line 89 at DotNetty.Transport.Channels.AbstractChannelHandlerContext.InvokeChannelRead(Object msg) ---> (Inner Exception #0) System.InvalidOperationException: Service rejected the message with status: 404 at Microsoft.Azure.Devices.Client.DeviceClient.<>c.<ApplyTimeout>b__74_2(Task t) at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Keatech.Thinkrace.Gateway.Handlers.Receiver.<OnMessageAsync>d__10.MoveNext() in D:\users\Dmytro\work\Keatech\git\Keatech.Thinkrace.Gateway\Handlers\Receiver.cs:line 110<---

3) System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Service rejected the message with status: 500 at Microsoft.Azure.Devices.Client.DeviceClient.<>c.<ApplyTimeout>b__74_2(Task t) at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Keatech.Thinkrace.Gateway.Handlers.Receiver.<OnMessageAsync>d__10.MoveNext() in D:\users\Dmytro\work\Keatech\git\Keatech.Thinkrace.Gateway\Handlers\Receiver.cs:line 110 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at Keatech.Thinkrace.Gateway.Handlers.Receiver.OnMessage(IChannelHandlerContext context, DeviceMessage message) in D:\users\Dmytro\work\Keatech\git\Keatech.Thinkrace.Gateway\Handlers\Receiver.cs:line 89 at DotNetty.Transport.Channels.AbstractChannelHandlerContext.InvokeChannelRead(Object msg) ---> (Inner Exception #0) System.InvalidOperationException: Service rejected the message with status: 500 at Microsoft.Azure.Devices.Client.DeviceClient.<>c.<ApplyTimeout>b__74_2(Task t) at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Keatech.Thinkrace.Gateway.Handlers.Receiver.<OnMessageAsync>d__10.MoveNext() in D:\users\Dmytro\work\Keatech\git\Keatech.Thinkrace.Gateway\Handlers\Receiver.cs:line 110<---

These exceptions seem to happen interchangeably, no matter what parameters of a DeviceClient.UpdateReportedPropertiesAsync call are.

A typical call looks like this: var patch = new TwinCollection(); patch["uploadInterval"] = 30; _deviceClient.UpdateReportedPropertiesAsync(patch);

This started to happen several days ago, without any visible reason. It happens many times a day and is really annoying.

CIPop commented 6 years ago

@zolvarga PTAL @simonporter FYI.

dmytro-gokun commented 6 years ago

@CIPop @zolvarga Guys, is there any chance this will be investigated/fixed any time soon? We see literally hundreds of these exceptions every day, they really disrupt our normal operations.

CIPop commented 6 years ago

@dmytro-gokun This appears to be a service-side issue. In general, for guaranteed response times or service issues please use the Azure Subscription support: https://github.com/azure/azure-iot-sdk-csharp#need-support

dmytro-gokun commented 6 years ago

@CIPop Okay, thanks for the advise. I've create a support ticket.

yzhong94 commented 6 years ago

@dmytro-gokun , thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey