For issues related to the code in this repository file a Github issue.
For general technical questions, post a question on StackOverflow
with the firebase tag.
For general Firebase discussion, use the firebase-talk
google group.
For help troubleshooting your application that does not fall under one
of the above categories, reach out to the personalized
Firebase support channel.
[REQUIRED] Step 2: Describe your environment
Operating System version: Windows 10
Firebase SDK version: 2.4.1
Firebase Product: Messaging
.NET version: 8.0.204
OS: Windows 10
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
Whenever I try to send a notification via FirebaseMessaging.SendAsync I get a timeout Exception.
Here's how I get my messaging instance:
var credential = ...; // Getting the private key from the database. It is the contents of the file that I get by clicking "Generate new private key" at https://console.firebase.google.com/project/[redacted for privacy]/settings/serviceaccounts/adminsdk
var instanceName = GetInstanceName(credential);
var app = FirebaseApp.GetInstance(instanceName) ?? FirebaseApp.Create(new AppOptions
{
Credential = GoogleCredential.FromJson(credential)
}, instanceName);
var messaging = FirebaseMessaging.GetMessaging(app);
Then I send the notification:
await messaging.SendAsync(new Message
{
Token = notification.DeviceToken,
Notification = new Notification
{
Title = "New Message!",
Body = notification.Text
}
});
At this point, the thread hangs for a while and it throws an exception:
System.Threading.Tasks.TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.
---> System.TimeoutException: A task was canceled.
---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Google.Apis.Auth.OAuth2.TokenRefreshManager.GetAccessTokenForRequestAsync(CancellationToken cancellationToken)
at Google.Apis.Auth.OAuth2.ServiceAccountCredential.GetAccessTokenForRequestAsync(String authUri, CancellationToken cancellationToken)
at Google.Apis.Auth.OAuth2.ServiceCredential.GetAccessTokenWithHeadersForRequestAsync(String authUri, CancellationToken cancellationToken)
at Google.Apis.Auth.OAuth2.ServiceCredential.InterceptAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Google.Apis.Http.ConfigurableMessageHandler.CredentialInterceptAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Google.Apis.Http.ConfigurableMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts,
Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at System.Net.Http.HttpClient.HandleFailure(Exception e, Boolean telemetryStarted, HttpResponseMessage response, CancellationTokenSource cts, Cancell
ationToken cancellationToken, CancellationTokenSource pendingRequestsCts)
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts,
Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at FirebaseAdmin.Util.ErrorHandlingHttpClient`1.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at FirebaseAdmin.Util.ErrorHandlingHttpClient`1.SendAndReadAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at FirebaseAdmin.Util.ErrorHandlingHttpClient`1.SendAndDeserializeAsync[TResult](HttpRequestMessage request, CancellationToken cancellationToken)
at FirebaseAdmin.Messaging.FirebaseMessagingClient.SendAsync(Message message, Boolean dryRun, CancellationToken cancellationToken)
at FirebaseAdmin.Messaging.FirebaseMessaging.SendAsync(Message message, Boolean dryRun, CancellationToken cancellationToken)
at FirebaseAdmin.Messaging.FirebaseMessaging.SendAsync(Message message, Boolean dryRun)
at FirebaseAdmin.Messaging.FirebaseMessaging.SendAsync(Message message)
at [Redacted for privacy].Service.NotificationService.HandleAndroid(DbContext db, Hotel hotel) in [Redacted for privacy]\Service\No
tificationService.cs:line 59
[READ] Step 1: Are you in the right place?
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
Whenever I try to send a notification via FirebaseMessaging.SendAsync I get a timeout Exception.
Here's how I get my messaging instance:
Then I send the notification:
At this point, the thread hangs for a while and it throws an exception: