Azure Notification Hub调用GetRegistrationsByChannelAsync抛TaskCanceledException求助
Azure Notification Hub GetRegistrationsByChannelAsync频繁抛出TaskCanceledException,dailyMaxActiceDevices触顶但未达总注册限制
我们的服务使用Azure Notification Hub推送通知,运行数月后,调用NotificationHub-Client的GetRegistrationsByChannelAsync方法时开始频繁抛出TaskCanceledException异常。
观察Azure Hub的监控数据发现,dailyMaxActiceDevices属性频繁触顶,但我们的基础订阅远未达到总注册设备的限制。该问题并非持续发生,但近期出现频率明显上升。我们没有修改过相关代码,也未在NotificationHub的官方文档或已知问题中找到对应内容,希望能得到排查思路。
异常堆栈跟踪
System.Threading.Tasks.TaskCanceledException: A task was canceled. at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.NotificationHubs.NotificationHubClient.d__201.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.NotificationHubs.NotificationHubClient.d__200.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.NotificationHubs.NotificationHubClient.d__192`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
抛出异常的代码
if (handle != null) { var registrations = await hub.GetRegistrationsByChannelAsync(handle, 100); foreach (RegistrationDescription registration in registrations) { if (newRegistrationId == null) { newRegistrationId = registration.RegistrationId; } else { await hub.DeleteRegistrationAsync(registration); } } }
内容的提问来源于stack exchange,提问作者Filoteemo
相关产品推荐
相关产品推荐

