firebase / firebase-admin-java

Firebase Admin Java SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
538 stars 264 forks source link

404 error Requested entity was not found, send message failed 80% #972

Closed Goii closed 1 month ago

Goii commented 1 month ago

version

com.google.firebase
        <artifactId>firebase-admin</artifactId>
        <version>9.2.0</version>

FirebaseMessaging instance = FirebaseMessaging.getInstance(object); ApiFuture batchResponseApiFuture = instance.sendEachAsync(list); BatchResponse response = batchResponseApiFuture.get();

send 10 same messages with different fireBaseToken ( different device ) . 7-8 messages failed .

error message is com.google.api.client.http.HttpResponseException: 404 Not Found POST https://fcm.googleapis.com/v1/projects/xxxxxx/messages:send { "error": { "code": 404, "message": "Requested entity was not found.", "status": "NOT_FOUND", "details": [ { "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError", "errorCode": "UNREGISTERED" } ] } }

help me!!!!

google-oss-bot commented 1 month ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

emindeniz99 commented 1 month ago

UNREGISTERED (HTTP error code = 404) App instance was unregistered from FCM. This usually means that the token used is no longer valid and a new one must be used.

https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode

Unregistered response is delivered with http 404 code. So it is normal.

your token can be invalid if user deletes application

Goii commented 1 month ago

@emindeniz99 i got it ,

now i get the error message

{ "exception": { "errorCode": "DEADLINE_EXCEEDED", "cause": { "retryCount": 3, "isRetryable": true, "cause": "java.net.SocketTimeoutException: connect timed out", "stackTrace": [ "com.google.auth.oauth2.GoogleAuthException.createWithTokenEndpointIOException(GoogleAuthException.java:164)", "com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken(ServiceAccountCredentials.java:543)", "com.google.auth.oauth2.OAuth2Credentials$1.call(OAuth2Credentials.java:269)", "com.google.auth.oauth2.OAuth2Credentials$1.call(OAuth2Credentials.java:266)", "java.util.concurrent.FutureTask.run(FutureTask.java:266)", "com.google.auth.oauth2.OAuth2Credentials$RefreshTask.run(OAuth2Credentials.java:633)", "com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:398)", "com.google.auth.oauth2.OAuth2Credentials$AsyncRefreshResult.executeIfNew(OAuth2Credentials.java:581)", "com.google.auth.oauth2.OAuth2Credentials.asyncFetch(OAuth2Credentials.java:232)", "com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:182)", "com.google.auth.oauth2.ServiceAccountCredentials.getRequestMetadata(ServiceAccountCredentials.java:938)", "com.google.auth.http.HttpCredentialsAdapter.initialize(HttpCredentialsAdapter.java:96)", "com.google.firebase.internal.FirebaseRequestInitializer.initialize(FirebaseRequestInitializer.java:55)", "com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:91)", "com.google.firebase.internal.HttpRequestInfo.newHttpRequest(HttpRequestInfo.java:105)", "com.google.firebase.internal.ErrorHandlingHttpClient.createHttpRequest(ErrorHandlingHttpClient.java:137)", "com.google.firebase.internal.ErrorHandlingHttpClient.send(ErrorHandlingHttpClient.java:92)", "com.google.firebase.internal.ErrorHandlingHttpClient.sendAndParse(ErrorHandlingHttpClient.java:72)", "com.google.firebase.messaging.FirebaseMessagingClientImpl.sendSingleRequest(FirebaseMessagingClientImpl.java:127)", "com.google.firebase.messaging.FirebaseMessagingClientImpl.send(FirebaseMessagingClientImpl.java:113)", "com.google.firebase.messaging.FirebaseMessaging$3.execute(FirebaseMessaging.java:248)", "com.google.firebase.messaging.FirebaseMessaging$3.execute(FirebaseMessaging.java:244)", "com.google.firebase.internal.CallableOperation.call(CallableOperation.java:36)", "com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)", "com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:57)", "com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)", "java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)", "java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)", "java.lang.Thread.run(Thread.java:748)" ] }, "stackTrace": [ "com.google.firebase.messaging.FirebaseMessagingException.withMessagingErrorCode(FirebaseMessagingException.java:51)", "com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingErrorHandler.createException(FirebaseMessagingClientImpl.java:293)", "com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingErrorHandler.createException(FirebaseMessagingClientImpl.java:282)", "com.google.firebase.internal.AbstractHttpErrorHandler.handleIOException(AbstractHttpErrorHandler.java:63)", "com.google.firebase.internal.ErrorHandlingHttpClient.createHttpRequest(ErrorHandlingHttpClient.java:141)", "com.google.firebase.internal.ErrorHandlingHttpClient.send(ErrorHandlingHttpClient.java:92)", "com.google.firebase.internal.ErrorHandlingHttpClient.sendAndParse(ErrorHandlingHttpClient.java:72)", "com.google.firebase.messaging.FirebaseMessagingClientImpl.sendSingleRequest(FirebaseMessagingClientImpl.java:127)", "com.google.firebase.messaging.FirebaseMessagingClientImpl.send(FirebaseMessagingClientImpl.java:113)", "com.google.firebase.messaging.FirebaseMessaging$3.execute(FirebaseMessaging.java:248)", "com.google.firebase.messaging.FirebaseMessaging$3.execute(FirebaseMessaging.java:244)", "com.google.firebase.internal.CallableOperation.call(CallableOperation.java:36)", "com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)", "com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:57)", "com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)", "java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)", "java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)", "java.lang.Thread.run(Thread.java:748)" ] }

Goii commented 1 month ago

404 UNREGISTERED = The token has expired.