diff --git a/firebase-messaging/CHANGELOG.md b/firebase-messaging/CHANGELOG.md index a5a447f5cde..eb8b9363394 100644 --- a/firebase-messaging/CHANGELOG.md +++ b/firebase-messaging/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased - +* [changed] Retry Topic Subscribe/Unsubscribe operations with exponential + backoff if they hit a quota error. # 24.0.0 * [changed] Switched Firelog to use the new TransportBackend. diff --git a/firebase-messaging/src/main/java/com/google/firebase/messaging/GmsRpc.java b/firebase-messaging/src/main/java/com/google/firebase/messaging/GmsRpc.java index 2f8e68bb519..5962fbc6999 100644 --- a/firebase-messaging/src/main/java/com/google/firebase/messaging/GmsRpc.java +++ b/firebase-messaging/src/main/java/com/google/firebase/messaging/GmsRpc.java @@ -58,6 +58,12 @@ class GmsRpc { /** Another server error besides ERROR_SERVICE_NOT_AVAILABLE that we retry on. */ static final String ERROR_INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR"; + /** + * A server error that represents hitting topic subscription quota. Trying again here may + * continue to fail, but as long as we use exponential backoff its okay to retry. + */ + static final String TOO_MANY_SUBSCRIBERS = "TOO_MANY_SUBSCRIBERS"; + /** Heartbeat tag for firebase iid. */ static final String FIREBASE_IID_HEARTBEAT_TAG = "fire-iid"; diff --git a/firebase-messaging/src/main/java/com/google/firebase/messaging/TopicsSubscriber.java b/firebase-messaging/src/main/java/com/google/firebase/messaging/TopicsSubscriber.java index ca532dcd684..6a5b72290cd 100644 --- a/firebase-messaging/src/main/java/com/google/firebase/messaging/TopicsSubscriber.java +++ b/firebase-messaging/src/main/java/com/google/firebase/messaging/TopicsSubscriber.java @@ -251,7 +251,8 @@ boolean performTopicOperation(TopicOperation topicOperation) throws IOException } catch (IOException e) { // Operation failed, retry failed only if errors from backend are server related error if (GmsRpc.ERROR_SERVICE_NOT_AVAILABLE.equals(e.getMessage()) - || GmsRpc.ERROR_INTERNAL_SERVER_ERROR.equals(e.getMessage())) { + || GmsRpc.ERROR_INTERNAL_SERVER_ERROR.equals(e.getMessage()) + || GmsRpc.TOO_MANY_SUBSCRIBERS.equals(e.getMessage())) { Log.e(TAG, "Topic operation failed: " + e.getMessage() + ". Will retry Topic operation."); return false; // will retry