MatthieuLemoine / electron-push-receiver

A module to bring Web Push support to Electron allowing it to receive notifications from Firebase Cloud Messaging (FCM).
https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0
MIT License
191 stars 62 forks source link

The service is currently unavailable #80

Open bhtri opened 3 years ago

bhtri commented 3 years ago

Hi @MatthieuLemoine Thank you for creating a great package. I tried to add in my project and have reference to the example project, can't get the token failed to boot successfully, and get the error as below.


PUSH_RECEIVER:::Error while starting the service StatusCodeError: 503 - "{\n  \"error\": {\n    \"code\": 503,\n    \"message\": \"The service is currently unavailable.\",\n    \"status\": \"UNAVAILABLE\"\n  }\n}\n"
    at new StatusCodeError ($MYHOME/my-electron-app/node_modules/request-promise-core/lib/errors.js:32:15)
    at Request.plumbing.callback $MYHOME/my-electron-app/node_modules/request-promise-core/lib/plumbing.js:104:33)
    at Request.RP$callback [as _callback] ($MYHOME/my-electron-app/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at Request.self.callback ($MYHOME/my-electron-app/node_modules/request/request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> ($MYHOME/my-electron-app/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:315:20)
    at IncomingMessage.<anonymous> ($MYHOME/my-electron-app/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:421:28)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  statusCode: 503,
  error: '{\n' +
    '  "error": {\n' +
    '    "code": 503,\n' +
    '    "message": "The service is currently unavailable.",\n' +
    '    "status": "UNAVAILABLE"\n' +
    '  }\n' +
    '}\n',
  options: {
    url: 'https://fcm.googleapis.com/fcm/connect/subscribe',
    method: 'POST',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    form: {
      authorized_entity: '$MYSENDERID',
      endpoint: 'https://fcm.googleapis.com/fcm/send/...',
      encryption_key: '',
      encryption_auth: ''
    },
    callback: [Function: RP$callback],
    transform: undefined,
    simple: true,
    resolveWithFullResponse: false,
    transform2xxOnly: false
  },
  .....
  }

package.json
{
  "devDependencies": {
    "electron": "^13.1.4"
  },
  "dependencies": {
    "electron-push-receiver": "^2.1.3"
  }
}

It seems endpoint of FCM has changed, how to update again? Thank you very much!

wtesler commented 2 years ago

Also getting this error

DE-Kato commented 2 years ago

NOTE: This issue seems to be occurring within push-receiver itself. The subscribe URL for Legacy "FCM HTTP API" was removed??

AshmitW commented 2 years ago

Also getting this error, is there any workaround for this that we can do?

DE-Kato commented 2 years ago

[Update] This error seems to have stopped happening today. I don't have any official information from Google, so I don't know what happened. 🤔

AshmitW commented 2 years ago

[Update] This error seems to have stopped happening today. I don't have any official information from Google, so I don't know what happened. 🤔

Did you change anything from your side? cause for me the issue is still there

DE-Kato commented 2 years ago

Hi @Ashmit-Nextus

Did you change anything from your side? cause for me the issue is still there

Unfortunately, I didn't do anything special about it, but it occurred for a few days and then resolved itself. Just last year, there was a similar failure report. I'm just hoping it's not something that happens every year around this time. 😅

https://status.firebase.google.com/incidents/rE4GeaMBDmYefDDuomVL

AshmitW commented 2 years ago

Oh unfortunately the error is still here for me, can @bhtri @wtesler confirm if something changed for you guys?

wtesler commented 2 years ago

I can't confirm, but what I do know is the 503 is coming from a GCM endpoint which I know Google is sunsetting (in favor of FCM), so it might just be the case that the endpoint is no longer available/supported.

On Wed, Jul 7, 2021, 10:50 AM Ashmit @.***> wrote:

Oh unfortunately the error is still here for me, can @bhtri https://github.com/bhtri @wtesler https://github.com/wtesler confirm if something changed for you guys?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MatthieuLemoine/electron-push-receiver/issues/80#issuecomment-875719009, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATABCLYVNNF23C364LE26TTWRZTHANCNFSM47T2HGAQ .

bhtri commented 2 years ago

Thank you to everyone who shared and commented! My error is still the same, even though I tried running electron-fcm-demo, and changing my Sender ID here, it still doesn't work (still the same error 😅). and I also tried trying to figure out how it works through @MatthieuLemoine post to make a pull request, but still can't fix it ...... 😭

DE-Kato commented 2 years ago

[Update.2] The issue has started to occur again this morning. 😥 I didn't do anything special about it, so I think you may be right about what you are saying.

YohaanYoon commented 2 years ago

Are there any updates?

bhtri commented 2 years ago

package & issue is still not update ....

YohaanYoon commented 2 years ago

If push-receiver is updated, is it possible to solve the issue? @bhtri

stephen79 commented 2 years ago

If push-receiver is updated, is it possible to solve the issue? @bhtri

nope, updated to latest 2.1.1, still doesn't work This is an issue originated from FCM service, the client can only retry registerFCM() until it successfully registered. https://github.com/stephen79/electron-push-receiver

bhtri commented 2 years ago

so now is there any way that electron app can receive notifications from Firebase Cloud Messaging (FCM)? and also created a question on stackoverflow but still no idea... 😥

DE-Kato commented 2 years ago

As mentioned here, we may no longer be able to invoke the FCM registration endpoint. https://github.com/MatthieuLemoine/push-receiver/issues/47#issuecomment-874251257

So, the possible (realistic) solution might be...using node-gyp, create a native addons for Google's C++ SDK.

Or, migrate to another service, such as Pushy or something.

rodent129 commented 2 years ago

@bhtri May be you can try a test with stephen79 push receiver. https://github.com/stephen79/electron-push-receiver

He added the retry logic for registering fcm token. We tested it today, after several tempt try, it finally succeeded with interval from several minutes to an hour or more. But at least got fcm token.

It is not published, so you can get it locally build.

Get the source project. Then

  1. run npm pack , you will get the .tgz file.

  2. copy this xx.tgz file to your project and

  3. npm install xx.tgz

  4. also you need to re register on error callback. something like below after a retry timer. setTimeout(() => { ipcRenderer.send(WindowEvent.MAIN_WIN, WindowEvent.MainWinEvent.RETRY_REGISTER_PUSH_SERVICE); }, this.retryFcmRegisterInterval);

    Increase your retry timer according to the 503 error in this documentation https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode

  5. build and run your project.

Try if it can work for you eventually.

osslate commented 2 years ago

So, the possible (realistic) solution might be...using node-gyp, create a native addons for Google's C++ SDK.

I've been looking into creating a native addon that links to firebase-cpp-sdk; it appears as though their SDK can be built for three different targets (Android, iOS, Desktop).

As you would expect, building for Android requires linking to Android/Java specific libraries, and building for iOS requires linking to iOS-specific libraries (Foundation, Cocoa, etc.)

Many of the Firebase API implementations in that SDK do appear to implement the desktop target, but unfortunately it appears Firebase Messaging doesn't. Building Firebase Messaging with the desktop target results in this stub being compiled, rather than anything useful. (see the CMakeLists.txt here).

I'm going to explore this a little more tomorrow, but with the understanding I have, I can see two possible solutions:

If anyone has been toying around with this idea or has better insight into this than I do (it's been a while since I've played around with C++), I'd be interested to hear how far you've gotten :)

davej commented 2 years ago

We have been seeing fewer 503 errors over the past few days. I saw a couple of them yesterday but all-in-all it seems to be on the downtrend. Does this match other people's experiences?

koush commented 2 years ago

@osslate I believe all 3 implementations leverage native platform APIs for push messaging. Firebase SDK does not provide a push implementation, it provides a unified way to access platform provided APIs.

The C++ API, as noted in their docs, targets the platform services.

To write your cross-platform Firebase Cloud Messaging client app with C++, use the Firebase Cloud Messaging API. The C++ SDK works for both Android and iOS, with some additional setup required for each platform.

Same with the javascript implementation, that requires the browser to support it:

The FCM JavaScript API lets you receive notification messages in web apps running in browsers that support the Push API. This includes the browser versions listed in this support matrix and Chrome extensions via the Push API.

Basically, the Android implementation needs to be reverse engineered again. It is likely just new endpoints.