firebase-admin-java icon indicating copy to clipboard operation
firebase-admin-java copied to clipboard

com.google.firebase.messaging.FirebaseMessagingException.getMessagingErrorCode() is null

Open maharavindran opened this issue 1 year ago • 2 comments

After moving to fcm 9.2.0 we are using sendEachForMultiCast while we send 500 device tokens per request , where we are facing issues with null error code for failure cases .(com.google.firebase.messaging.FirebaseMessagingException.getMessagingErrorCode() is null)

maharavindran avatar Aug 27 '24 09:08 maharavindran

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

google-oss-bot avatar Aug 27 '24 09:08 google-oss-bot

we could see message Timed out while making an API call: Read timed out errors while printing exception messages in case of null.

maharavindran avatar Aug 27 '24 11:08 maharavindran

Hi maharavindran,

Could you provide a full stack trace for failure cases mentioned above? Additionally, please try sending a smaller batch of device tokens, perhaps 100 per request.

Doris-Ge avatar Aug 30 '24 20:08 Doris-Ge

@Doris-Ge we did increase our read and connect timeouts to 30 seconds with 500 device tokens , failures drastically reduced . But here is the stack trace for few of the failures during burst traffic , "Timed out while making an API call: Connect timed out" " Unexpected HTTP response with status: 401" " Unknown error while making a remote service call: Remote host terminated the handshake" "Request contains an invalid argument" "Cannot invoke "com.google.firebase.IncomingHttpResponse.getStatusCode()" because the return value of "com.google.firebase.messaging.FirebaseMessagingException.getHttpResponse()" is null" most of the time its the timed out message during burst traffic

maharavindran avatar Aug 30 '24 21:08 maharavindran

Thanks @maharavindran!

I'm glad to hear that increasing timeouts helped reduce the failures! Sending to a large batch of device tokens can be slow because sendEachForMultiCast sends an HTTP request for each device token. If you send to 500 tokens, the sendEachForMultiCast function call will have to wait for 500 HTTP requests to complete before it returns.

You can also consider other options to mitigate this:

  • Sending to a smaller batch such as 100.
  • Implementing your own version of sendEachForMultiCast with HTTP/2 clients.

Doris-Ge avatar Aug 30 '24 23:08 Doris-Ge