firebase_cloud_messenger icon indicating copy to clipboard operation
firebase_cloud_messenger copied to clipboard

Too many retries don't cause client to raise

Open padarom opened this issue 4 years ago • 0 comments

In our case the client keeps receiving responses with code 401. The FCM authentication works fine, but the configured APNS key doesn't seem to be working temporarily, so the FCM servers aren't able to properly authenticate with Apple and just bubble the 401 back to the client. The response includes that information, but since it also happens to be a 401 it just keeps trying to refresh its access token until it times out.

https://github.com/vincedevendra/firebase_cloud_messenger/blob/f96bcd6dcb0d04d67144029497d7f50e3d273efc/lib/firebase_cloud_messenger/client.rb#L24-L30

{"error"=>
  {"code"=>401,
   "message"=>"Auth error from APNS or Web Push Service",
   "status"=>"UNAUTHENTICATED",
   "details"=>
    [{"@type"=>"type.googleapis.com/google.firebase.fcm.v1.FcmError",
      "errorCode"=>"THIRD_PARTY_AUTH_ERROR"}]}}

I'd expect the client to raise if the final retry wasn't successful, but as it stands it just returns the above error. Is there a specific reason why that's not the case or would a PR that changes this behavior be welcome?

padarom avatar May 19 '20 13:05 padarom