Azure Notification Hub. The remote server returned an error: (404) Not Found. NotificationId cannot be found

Azure Notification Hub. The remote server returned an error: (404) Not Found. NotificationId cannot be found

我正在使用 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)

有人可以提供帮助吗?

A​​FAIK,GetNotificationOutcomeDetailsAsync 将利用 REST API Per Message Telemetry: Get Notification Message Telemetry。对于404响应码,官方文档有如下说明:

Telemetry does not exist. This may be because the notification ID is invalid or because the message has not progressed far enough in processing. If you receive a 404 code, wait and try again after 10s. This state can continue for up to 30 minutes.

注意:以上API仅适用于Standard tier notification hubs. Moreover, you could follow Diagnose dropped notifications in Notification Hubs,缩小问题范围