Azure通知中心。远程服务器返回错误:(404)Not Found。无法找到NotificationId

时间:2018-04-03 14:39:44

标签: c# .net azure azure-notificationhub azure-sdk-.net

我正在使用Azure .Net SDK。 当我SendDirectNotificationAsync时,我会收到NotificationOutcome。然后我从结果中得到NotificationId,然后立即GetNotificationOutcomeDetailsAsync。我收到404错误的回复。但如果我再试一次,我会得到NotificationDetail

代码:

var outcome = hub.SendDirectNotificationAsync(notification, messageCreated.Entity.PushToken).Result;

不幸的是,我无法使用await

例外:

Microsoft.Azure.NotificationHubs.Messaging.MessagingEntityNotFoundException: The remote server returned an error: (404) Not Found. NotificationId 'dcd8c78360d24dfa9e99dadfc6b68593-20180403085427-2001954715-1' cannot be found.TrackingId:1f5a51d0-547a-428d-a845-7a164baebf74_G13,TimeStamp:4/3/2018 8:54:27 AM
  Module "Microsoft.Azure.NotificationHubs.Common.ExceptionDispatcher", line 7, col 0, in Throw
    Void Throw(System.Exception)
  Module "Microsoft.Azure.NotificationHubs.Common.AsyncResult", line 310, col 0, in End
    TAsyncResult End[TAsyncResult](System.IAsyncResult)
  Module "Microsoft.Azure.NotificationHubs.NotificationHubManager+<>c", line 0, col 0, in GetNotificationAsync { <lambda> }
    Microsoft.Azure.NotificationHubs.NotificationDetails <GetNotificationAsync>b__24_1(System.IAsyncResult)
  Module "System.Threading.Tasks.TaskFactory 1", line 15, col 0, in FromAsyncCoreLogic
    Void FromAsyncCoreLogic(System.IAsyncResult, System.Func 2[System.IAsyncResult,TResult], System.Action 1[System.IAsyncResult], System.Threading.Tasks.Task 1[TResult], Boolean)
System.Net.WebException: The remote server returned an error: (404) Not Found.
  Module "System.Net.HttpWebRequest", line 273, col 0, in EndGetResponse
    System.Net.WebResponse EndGetResponse(System.IAsyncResult)
  Module "Microsoft.Azure.NotificationHubs.NotificationRequestAsyncResult 1+<>c", line 0, col 0, in GetAsyncSteps { <lambda> }
    Void <GetAsyncSteps>b__26_3(TAsyncResult, System.IAsyncResult)
  Module "Microsoft.Azure.NotificationHubs.Messaging.IteratorAsyncResult`1", line 44, col 0, in StepCallback
    Boolean StepCallback(System.IAsyncResult)

有人可以提供任何帮助吗?

1 个答案:

答案 0 :(得分:1)

AFAIK,GetNotificationOutcomeDetailsAsync将利用REST API Per Message Telemetry: Get Notification Message Telemetry。对于404响应代码,官方文档声明如下:

  

遥测不存在。这可能是因为通知ID无效,或者因为消息在处理过程中进展不够。如果您收到404代码,请等待10秒后重试。这种状态可以持续长达30分钟。

注意:以上API仅适用于Standard tier notification hubs。此外,您可以按Diagnose dropped notifications in Notification Hubs缩小此问题的范围。