Firebase FCM timeout when fetching token from android client

116 views
Skip to first unread message

Kim Hui Beom

unread,
Aug 27, 2024, 12:42:23 PMAug 27
to Firebase Google Group
Dear firebase community,

I'm currently working on an Android Jetpack Compose project that utilizes Firebase FCM for handling push notifications. 

My app fetches FCM token during the app's initial launch and while fetching the token, I get TIMEOUT exception:

```
java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: TIMEOUT (Ask Gemini)
at com.google.firebase.messaging.FirebaseMessaging.blockingGetToken(FirebaseMessaging.java:665)
at com.google.firebase.messaging.FirebaseMessaging.lambda$getToken$7$com-google-firebase-messaging-FirebaseMessaging(FirebaseMessaging.java:421)
at com.google.firebase.messaging.FirebaseMessaging$$ExternalSyntheticLambda11.run(D8$$SyntheticClass:0)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.3.0:2)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.util.concurrent.ExecutionException: java.io.IOException: TIMEOUT
at com.google.android.gms.tasks.Tasks.zza(com.google.android.gms:play-services-tasks@@18.1.0:5)
at com.google.android.gms.tasks.Tasks.await(com.google.android.gms:play-services-tasks@@18.1.0:9)
at com.google.firebase.messaging.FirebaseMessaging.blockingGetToken(FirebaseMessaging.java:663)
at com.google.firebase.messaging.FirebaseMessaging.lambda$getToken$7$com-google-firebase-messaging-FirebaseMessaging(FirebaseMessaging.java:421) 
at com.google.firebase.messaging.FirebaseMessaging$$ExternalSyntheticLambda11.run(D8$$SyntheticClass:0) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487) 
at java.util.concurrent.FutureTask.run(FutureTask.java:264) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) 
at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.3.0:2) 
at java.lang.Thread.run(Thread.java:1012) 
Caused by: java.io.IOException: TIMEOUT
at com.google.android.gms.cloudmessaging.zzac.run(com.google.android.gms:play-services-cloud-messaging@@17.2.0:1)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012) 
```

Interestingly, this exception does not occur on another device with the exact same model (Samsung Galaxy) and identical source code. Below is the code where the exception is occurring:

```

private suspend fun fetchFCMToken(): Result<String, AppException> {
return suspendCancellableCoroutine { cont ->
FirebaseMessaging.getInstance().token.addOnCompleteListener { task -> // <-- exception occurs here
if (task.isSuccessful) {
val token = task.result
cont.resume(Ok(token))
} else {
cont.resume(Err(AppException.Repository.CannotFetchFcmTokenException()))
}
}
}
}

```

I have attempted a factory reset of the affected device, but the exception still persists. The internet connection was stable when the error occurred. I also tried deleting and recreating the Firebase project in the Firebase console, but this did not resolve the issue.

Did anyone encountered similar problem before?

Thank you for all your support.

Kim Hui Beom

unread,
Aug 28, 2024, 9:59:59 AMAug 28
to Firebase Google Group
I found the cause of the problem, which had to do with device specific settings rather than with the code or the firebase fcm server. I can't really share the details but just wanted to update that issue has been resolved.
Reply all
Reply to author
Forward
0 new messages