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

messaging/internal-error only IOS

Open waqas740 opened this issue 3 years ago • 16 comments

code is working fine when I try to send notification on android but it does not work for IOS notification. Getting the below error:

{
  "results": [
    {
      "error": {
        "code": "messaging/internal-error",
        "message": "An internal error has occurred. Please retry the request."
      }
    }
  ],
  "canonicalRegistrationTokenCount": 0,
  "failureCount": 1,
  "successCount": 0,
  "multicastId": 8118740071861272000
}

This is my code sample

return await admin.messaging()
          .sendToDevice(deviceToken, {
   data: {
       title: 'Test Fcm',
       body: 'tesing fmc body',
       content_available: 'true',
       priority: 'high',
       requestId: '1',
       doctorId: '1',
       name: 'waqas',
       patientId: '1',
       action_type: 'TEST'
     },
     notification: {
       title: 'Test Fcm',
       body: 'tesing fmc body',
       content_available: 'true',
       priority: 'high'
     }
   }
  , {
   priority: "high",
   timeToLive: 60 * 60 * 24,
   contentAvailable:true,
}).catch(err => {
              console.log(err);
            
          })

waqas740 avatar Aug 19 '20 15:08 waqas740

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 19 '20 15:08 google-oss-bot

Sorry, this is not a product I am familiar with.

schmidt-sebastian avatar Aug 19 '20 16:08 schmidt-sebastian

I'm receiving quite the same error using sendToDevice (in the last week)

I'm sending this data:

{
  "notification": {
    "badge": "1",
    "body": "my message",
    "title": "my title",
    "priority": "high",
    "notId": "1599030685610",
    "content_available": "1",
    "sound": "default",
    "forceStart": "1"
  },
  "data": {
    "objID": "jjXZUjl...",
    "objOwnerID": "SRj3V4...",
    "userActionID": "GK6AM...",
    "userRecipientID": "SRj3V...",
    "text": "my text",
    "type": "new_like",
    "subType": "post"
  }
}

and FCM returns me this error:

{
  "results": [
    {
      "error": {
        "code": "messaging/unknown-error",
        "message": "An unknown server error was returned. Raw server response: \"\"InvalidParameters: The data field in the request can not contain duplicate keys.\"\""
      }
    }
  ],
  "canonicalRegistrationTokenCount": 0,
  "failureCount": 1,
  "successCount": 0,
  "multicastId": 2963338467847546000
}

I tried to contact the support, but still no one answered me.

Maybe something has changed??

giuseeFG avatar Sep 02 '20 07:09 giuseeFG

they answered me in this way:

This is Yuji. Happy to help you out.

There was an outage regarding internal server errors for iOS devices, that affected a small percentage of users. It will give an error when the request has multiple "content_available" parameters, which is the issue in your case. A number of customers have been affected by a change that was recently made to the API service. The issue was escalated to our engineering team and a mitigation was rolled out.

If you have any other questions or concerns, feel free to reach back. Cheers,

I removed "contentAvailable" in the payload.options object and it worked 👍

giuseeFG avatar Sep 03 '20 08:09 giuseeFG

@chong-shao is there anything that should be done in the SDK side for this? Looks like a fix has been deployed at the backend.

hiranya911 avatar Nov 06 '20 21:11 hiranya911

There's still remaining work for the backend team on this. I'll provide more updates once the fix is fully deployed.

chong-shao avatar Nov 10 '20 04:11 chong-shao

Any updates on this? We have this error happening intermittently; overall we can't seem to use Firebase reliably to send notifications to users, and our users depend on it.

superzadeh avatar Jan 14 '21 18:01 superzadeh

Hi @superzadeh do you have content_available set in your request, as the ones posted above in this thread? If so could you try remove content_available and retry the request?

As for the backend's fix deployment, is has not completed yet.

chong-shao avatar Jan 14 '21 18:01 chong-shao

Hi, i'm having the same issue too, and no i do not have the content_available in my payload

tomershohet avatar Jan 20 '21 14:01 tomershohet

Found the issue - They recently changed it on FCM so they do not allow to sent TEXT and BODY keys. From now on - we should only use the "Body". Once I removed the "Text" key from the notification object - everything works fine again.

tomershohet avatar Jan 20 '21 18:01 tomershohet

@tomershohet's answer worked very well. Had the issue with Android (iOS still got messages). After removing the "text" Key everything works fine again on both device types.

Shadowsith avatar Feb 02 '21 14:02 Shadowsith

This is still not reliably working for me. I have 'body' instead of 'text', and I don't have 'content-available' in the payloads. It only randomly fails, works 80-90% time.

isonlaxman avatar May 13 '22 22:05 isonlaxman

I'm also seeing about a 75% success rate on iOS push notifications when the app is either in the background or closed. But when the app is in the foreground, the success rate seems to be 100% (across 10 tests). Here's the data I'm sending:

 payload = {
    token: fcmToken,
    notification: {
        title: title,
        body: message,
    },
    data: {
        body: message,
    },
};

Was anyone able to isolate why this happens? Thanks!

dustinkerstein avatar Jun 28 '22 18:06 dustinkerstein

Quick update. I just ran another 10 tests today with the app closed and all 10 were a success. So maybe this error sometimes does indicate an actual internal Firebase cloud network issue.

dustinkerstein avatar Jun 30 '22 01:06 dustinkerstein

any update about this issue? i am also facing same issue

Sohailze avatar Sep 14 '22 04:09 Sohailze

For the issues posted in comments starting from May 13, this may caused by a separate problem. I'd recommend file a customer ticket through Firebase Support where you can provide more information about your request. The support team will reach out to help. Thanks!

chong-shao avatar Sep 19 '22 23:09 chong-shao

Closing due to inactivity

lahirumaramba avatar Jan 17 '23 20:01 lahirumaramba

My Code is Nodejs, Its not working only IOS , Android is working fine Error return : internalServerError async function PNF(data){ var fcm = new FCM(process.env.FCM_KEY); var message = { to:data.token, code:data.code, data:data.body, notification: { title: 'Posterz', body: data.title, sound: "ping.aiff",

      }
    };
console.log(JSON.stringify(message),"======================= android push");
fcm.send(message, function(err, response) {
  if(err){
    console.log('error found', err);
  }else {
    console.log('response here', response);
  }
})

}

raghav53 avatar Oct 03 '23 04:10 raghav53