Azure / azure-notificationhubs-dotnet

.NET SDK for Azure Notification Hubs
MIT License
70 stars 119 forks source link

[BUG] MessagingEntityNotFoundException when getting notification outcome details #299

Open Solethia opened 8 months ago

Solethia commented 8 months ago

Describe the bug When getting notification outcome details a MessagingEntityNotFoundException is thrown for some notifications even after waiting 30 or more minutes after the notification was enqueued.

Exception or Stack Trace

Microsoft.Azure.NotificationHubs.Messaging.MessagingEntityNotFoundException
   at Microsoft.Azure.NotificationHubs.NotificationHubClient.<SendRequestAsync>d__201.MoveNext()
   at Microsoft.Azure.NotificationHubs.NotificationHubClient.<SendRequestAsync>d__200.MoveNext()
   at Microsoft.Azure.NotificationHubs.NotificationHubClient.<>c__DisplayClass80_0.<<GetNotificationOutcomeDetailsAsync>b__0>d.MoveNext()
   at Microsoft.Azure.NotificationHubs.NotificationHubRetryPolicy.<RunOperation>d__4`1.MoveNext()
   at Microsoft.Azure.NotificationHubs.NotificationHubRetryPolicy.<RunOperation>d__4`1.MoveNext()
   at Microsoft.Azure.NotificationHubs.NotificationHubClient.<GetNotificationOutcomeDetailsAsync>d__80.MoveNext()
   at [Redacted].Queues.Triggers.LoyaltyNotificationOutcomeTrigger.<TryGetNotificationDetails>d__10.MoveNext() 

   in C:\Users\[Redacted]\source\repos\[Redacted]\[Redacted]\[Redacted].Queues\Triggers\LoyaltyNotificationOutcomeTrigger.cs:line 119

To Reproduce

  1. Use Microsoft.Azure.NotificationHubs nuget package version 4.1.0.
  2. Ensure hub namespace set to standard pricing
  3. Send notification Microsoft.Azure.NotificationHubs.NotificationHubClient.SendFcmNativeNotificationAsync(string jsonPayload, IEnumerable<string> tags) or Microsoft.Azure.NotificationHubs.NotificationHubClient.SendNotificationAsync(Notification notification, IEnumerable<string> tags)
  4. Save NotificationOutcome.NotificationId
  5. Poll NotificationId Microsoft.Azure.NotificationHubs.NotificationHubClient.GetNotificationOutcomeDetailsAsync(string notificationId)

Code Snippet Add the code snippet that causes the issue.

public async Task GetOutcomeDetails()
{
    var credentials =  new HubCredentials(
        connectionString: [RedactedFullSharedNotificationHubConnectionString],
        hubName: "[RedactedHubName]"
    var hub = NotificationHubClient.CreateClientFromConnectionString(credentials.ConnectionString, credentials.HubName);
    var result = await hub.GetNotificationOutcomeDetailsAsync(notificationId);
}

Expected behavior Expected to get outcome details.

Screenshots image

Setup (please complete the following information):

Additional context Add any other context about the problem here.

In our production code we use a ASPNET Api endpoint to send notifications. Once sent we use the notification id from the outcome to enqueue a message for polling the notificationId outcome details in a QueueTrigger. Currently we have quite a few messages that end up in our poison queue due to this issue.

Context TrackingId: 50f576d9-74bf-48f0-9ed9-9d19eb695aa7 TimeStamp: 10/11/2023 1:36:41 PM +00:00

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report