mozilla-services / autopush

Python Web Push Server used by Mozilla
https://autopush.readthedocs.io/
Mozilla Public License 2.0
217 stars 34 forks source link

Why dynamoDB ? Can this run without depending on AmazonAWS? #763

Closed v3ss0n closed 7 years ago

v3ss0n commented 7 years ago

Can we run it totally independent from thirdparty ?

bbangert commented 7 years ago

You can use Amazon's local DynamoDB JAR file to run it without a third party, yes. The instructions for this are here: http://autopush.readthedocs.io/en/latest/running.html

Which will run everything needed locally via docker-compose.

The architecture docs explain more of the rationale for why we're using DynamoDB. The tl;dr version is we need something that can handle tens of thousands of write/reads per second, that's consistent, and is fault tolerant ideally without needing an entire team of ops dedicated to the db (which seems typical with things like Cassandra).

v3ss0n commented 7 years ago

There is a database that dedicated for that. https://github.com/rethinkdb/rethinkdb I do not want to use GCM so i am looking for opensource webpush. So it seems i have to re-implement my own since we cannot use third party db as a requirement ?

bbangert commented 7 years ago

GCM provides messaging to Chrome and Android. This project provides a Push channel for WebPush to Firefox clients. They both have different protocols they speak to the browser, so they are not interchangeable. If you are going to send messages to a Chrome/Android user-agent, you must use GCM or a restricted subscription with Google's servers.

What exactly are you trying to do?

v3ss0n commented 7 years ago

Oh, i just want to do push notification alerts for an internal chat room inside serviceworker. We use chrome and android but want to avoid gcm, and looking opensource alternative.currently we are doing with serviceworker and eventsource but just found out that serviceworkers are only short lived and need push for that.

On Sun, Dec 18, 2016, 05:24 Ben Bangert notifications@github.com wrote:

GCM provides messaging to Chrome and Android. This project provides a Push channel for WebPush to Firefox clients. They both have different protocols they speak to the browser, so they are not interchangeable. If you are going to send messages to a Chrome/Android user-agent, you must use GCM or a restricted subscription with Google's servers.

What exactly are you trying to do?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mozilla-services/autopush/issues/763#issuecomment-267792323, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZnFjw0eFZPiE21wcaJLUtIrxida2lzks5rJGghgaJpZM4LP9gV .

v3ss0n commented 7 years ago

I thought the protocol was already, opensourced ?

On Sun, Dec 18, 2016, 06:27 Phyo Arkar phyo.arkarlwin@gmail.com wrote:

Oh, i just want to do push notification alerts for an internal chat room inside serviceworker. We use chrome and android but want to avoid gcm, and looking opensource alternative.currently we are doing with serviceworker and eventsource but just found out that serviceworkers are only short lived and need push for that.

On Sun, Dec 18, 2016, 05:24 Ben Bangert notifications@github.com wrote:

GCM provides messaging to Chrome and Android. This project provides a Push channel for WebPush to Firefox clients. They both have different protocols they speak to the browser, so they are not interchangeable. If you are going to send messages to a Chrome/Android user-agent, you must use GCM or a restricted subscription with Google's servers.

What exactly are you trying to do?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mozilla-services/autopush/issues/763#issuecomment-267792323, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZnFjw0eFZPiE21wcaJLUtIrxida2lzks5rJGghgaJpZM4LP9gV .

jrconlin commented 7 years ago

Ah. The reason we bridge over GCM is because mobile devices will consume more battery if there are additional connections. Mobile devices are very aggressive about shutting down unprivileged applications meaning that you may miss notifications or your device battery may not last very long. By using GCM, we take advantage of the existing, privileged channel that Google has in place. Much like how the data travels over our server, your messages are encrypted over GCM as well.

jrconlin commented 7 years ago

The WebPush protocol is a (brand new) RFC standard (8030), however Push Service providers are at liberty to use whatever protocol is most efficient between their servers and User Agents. Our service currently uses WebSocket, Google used FCM, etc.

jrconlin commented 7 years ago

For your usage, I'd imagine you could use WebPush as is. Yes, there are elements that require other, proprietary protocols when going to mobile devices, but that's going to be the case regardless. (Well, until they open up GCM and the other wire protocols.)

ghost commented 7 years ago

We use chrome and android but want to avoid gcm, and looking opensource alternative.

I don't think Chrome on Desktop or Android lets you use a different push server, unfortunately. (Please correct me if I'm wrong!) Firefox lets you use your own push server via a custom pref (dom.push.serverURL), but not Chrome. If you want to send push messages to a Chrome, you have to use GCM.

v3ss0n commented 7 years ago

But this autopush is not possible to use with chrome ?

On Sun, Dec 18, 2016, 06:33 JR Conlin notifications@github.com wrote:

The WebPush protocol is a (brand new) RFC standard (8030), however Push Service providers are at liberty to use whatever protocol is most efficient between their servers and User Agents. Our service currently uses WebSocket, Google used FCM, etc.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mozilla-services/autopush/issues/763#issuecomment-267795001, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZnFlmOmpX9RNcYSPg0PJOj9TT4SNXUks5rJHhlgaJpZM4LP9gV .

ghost commented 7 years ago

But this autopush is not possible to use with chrome ?

Correct. It's not possible to make Chrome use Autopush instead of GCM/FCM.

v3ss0n commented 7 years ago

Thanks alot! sorry for the confusion. RFC 8030 is not supported by chrome yet? I can't find it . Is there no opensource implementation ? I am also wondering OneSIgnal is also doing push notification via GCM too ?

On Sun, Dec 18, 2016 at 6:40 AM Kit Cambridge notifications@github.com wrote:

But this autopush is not possible to use with chrome ?

Correct. It's not possible to make Chrome use Autopush instead of GCM/FCM.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mozilla-services/autopush/issues/763#issuecomment-267795222, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZnFgNfuhDxthnXvPROYrx-nf6j7ZDDks5rJHnXgaJpZM4LP9gV .

ghost commented 7 years ago

No worries, sorry this is confusing.

RFC 8030 is not supported by chrome yet?

To recap Ben and JR's comments, there are two sides to RFC 8030.

The first part is the server side. It describes how you send messages to the push server for delivery. Chrome 52+ does support this. If you create a push subscription using VAPID (serviceWorkerRegistration.pushManager.subscribe({ applicationServerKey: new Uint8Array([ ... ]), userVisibleOnly: true })), you'll get an https://fcm.googleapis.com/fcm/send/... endpoint.

This is a Web Push endpoint: you can send encrypted messages to it, and use VAPID instead of a GCM API key to authenticate. It's still using the GCM/FCM server to deliver the message, but the endpoint uses the Web Push protocol instead of the FCM protocol.

The second part of RFC 8030 is the client side. It describes how the push server delivers those messages to the browser. AFAIK, Chrome has no plans to implement this, or let you use a different server. So, even if you set up your own push server, you couldn't use it to send messages to Chrome.

Is there no opensource implementation ?

I'm not quite sure what you mean. There's no open source version of FCM/GCM. Even if there were, though, you'd need a way to tell Chrome, "use my push server instead of fcm.googleapis.com". And it's not possible to configure Chrome to do that.

I am also wondering OneSIgnal is also doing push notification via GCM too

Yes, all messages sent to Chrome go through FCM/GCM.

ghost commented 7 years ago

Earlier, you said:

Oh, i just want to do push notification alerts for an internal chat room inside serviceworker. We use chrome and android but want to avoid gcm

Can you explain why you want to avoid FCM/GCM? All messages sent to Chrome are end-to-end encrypted. Google can't read them in transit; only Chrome can decrypt the message. (FWIW, Mozilla can't read push messages you send to Firefox, either).

As JR says, it sounds like you can just use Web Push as is. I'm not sure why you'd need to run your own push server. Or maybe I'm misunderstanding what you're trying to do?

v3ss0n commented 7 years ago

Main reason is we want to have full control over architecture. GCM is quite slow in Myanmar. Latency of well over 400ms.

bbangert commented 7 years ago

Well, if you want to avoid GCM, you'll need to require that your users all run Firefox and change the push provider in the Firefox config settings to use your running autopush. The running instructions above that I linked to would let you run it locally without any third parties. I assume this is some in-house application?

If it's a public application and you have no control of the browsers people use, then there is no alternative to what the browser vendor supplies.

It's also worth noting that if 400ms is too long to wait, then WebPush might not be what you want to use, because it's not built with such delivery constraints in mind.