Describe the bug
Sometimes when my ASP.NET Core server is calling the Azure Notification Hub to register or update a push token the notification hub server returns a 502/bad gateway error. This happens quite frequently.
Exception or Stack Trace
AppInsights's error information for a call that returns 502 (with ids blanked out):
Code Snippet
public Task CreateOrUpdateInstallation(string installationId, string deviceToken, SharedConstants.PushPlatform pushPlatform, string[] additionalTags = null)
{
var platform =
pushPlatform == SharedConstants.PushPlatform.Apns ? NotificationPlatform.Apns :
(pushPlatform == SharedConstants.PushPlatform.Fcm ? NotificationPlatform.Fcm : throw new UserArgumentException("Invalid push platform"));
var tags = new List<string>()
{
installationId
};
if (additionalTags != null)
tags.AddRange(additionalTags);
var templates = new Dictionary<string, InstallationTemplate>(Templates.Count);
foreach (var kvp in Templates)
templates.Add(kvp.Key, kvp.Value[platform]);
var installation = new Installation()
{
InstallationId = installationId,
PushChannel = deviceToken,
Platform = platform,
Tags = tags,
Templates = templates
};
// TODO: segment based on LoginSession.NotificationNamespaceIndex. must segment every 10M to a new notification hub namespace
return this.Hub()?.CreateOrUpdateInstallationAsync(installation) ?? Task.CompletedTask; // error: this call will often return status code 502!!
}
Expected behavior
CreateOrUpdateInstallationAsync should return status code 200. Instead, 502/bad gateway is often returned.
Setup (please complete the following information):
OS: Azure App Service/Windows
IDE : VS For Mac 8.10
Version of the Library used: 4.1.0
ASP.NET Core project, target framework: .NET 5.0
Additional context
If I retry the call (i.e. run the above CreateOrUpdateInstallation(...) -> this.Hub()?.CreateOrUpdateInstallationAsync(...)) again, it seems to always succeed on the second try.
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
[x ] Bug Description Added
[x ] Repro Steps Added
[x ] Setup information Added
This is hurting me quite badly, so a quick resolution would be greatly appreciated!
Thank you.
Describe the bug Sometimes when my ASP.NET Core server is calling the Azure Notification Hub to register or update a push token the notification hub server returns a 502/bad gateway error. This happens quite frequently.
Exception or Stack Trace AppInsights's error information for a call that returns 502 (with ids blanked out):
Code Snippet
Expected behavior CreateOrUpdateInstallationAsync should return status code 200. Instead, 502/bad gateway is often returned.
Setup (please complete the following information):
Additional context If I retry the call (i.e. run the above
CreateOrUpdateInstallation(...) -> this.Hub()?.CreateOrUpdateInstallationAsync(...)
) again, it seems to always succeed on the second try.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
This is hurting me quite badly, so a quick resolution would be greatly appreciated! Thank you.