1

Due to default backoff/retry on notification failure my threads remain blocked for longer which impact the positive flow of my application. I don't want this retry or want to minimize it. The logic am using to create FirebaseApp is:

FileInputStream serviceAccount = new FileInputStream("fileName");
FirebaseOptions options = new FirebaseOptions.Builder()
  .setCredentials(GoogleCredentials.fromStream(serviceAccount))
  .build();

FirebaseApp app  = FirebaseApp.initializeApp(options, vendorId);

After that i set data and send request to FCM server as:

Message.Builder builder = Message.builder
          .setToken(fcmToken);

//put required payload data       
builder.putData("key", "value");

//Added android Configs
AndroidConfig androidConfigs = AndroidConfig.builder()
              .setTtl(30000)
              .setPriority(AndroidConfig.Priority.HIGH)
              .build();
builder.setAndroidConfig(androidConfigs);

//sending request to FCM
app.sendAsync(builder.build(), false);

I read a suggestion, it was told that Retry-After header will help in this, am not sure where to add in my code. Please suggest me, Thanks in advance.

Suryakant
  • 11
  • 1
  • SDK already handles `Retry-After` if it's available in the error responses sent by the FCM backend service. What's causing your API calls to fail? – Hiranya Jayathilaka Jun 15 '20 at 19:12
  • There are some expired FCM token for few users. due to which am getting failure. Generally i mark such mobile entry as inactive once user log out from a mobile app and our back-end never try to send notifications on inactive mobile entries. But if user uninstalls the app in that case i don't receive any request at server side to mark that mobile inactive and here problem starts. So can i disable or set to minimum this backoff option, as my threads are getting stuck here for longer? – Suryakant Jun 16 '20 at 05:28
  • The error am getting is: Caused by: com.google.api.client.http.HttpResponseException: 404 Not Found { "error": { "code": 404, "message": "Requested entity was not found.", "status": "NOT_FOUND", "details": [ { "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError", "errorCode": "UNREGISTERED" } ] } } – Suryakant Jun 16 '20 at 06:05
  • SDK doesn't retry 404 errors. It only retries 503 (Unavailable) errors. Your slow down is likely caused by some other reason. – Hiranya Jayathilaka Jun 16 '20 at 16:57
  • Thanks for answer. Please suggest how i can control/minimize the retry and reduce/remove backoff time in case of 500 and 503 errors. – Suryakant Jun 18 '20 at 18:55
  • Today there's no way to configure the retry durations. You should file a feature request for that. Also 500 and 503 errors are supposed to be quite rare. If you're encountering them often, you should look into that too. – Hiranya Jayathilaka Jun 18 '20 at 23:02

0 Answers0