Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

410 error just after registration #997

Closed
magne4000 opened this issue Sep 1, 2017 · 4 comments
Closed

410 error just after registration #997

magne4000 opened this issue Sep 1, 2017 · 4 comments
Assignees

Comments

@magne4000
Copy link

magne4000 commented Sep 1, 2017

I'm trying to get hands on the API, and I don't get why I'm getting a 410 error.

Register to webpush, this works:

curl 'https://updates.push.services.mozilla.com/v1/webpush/11-TESTING-11/registration' --data-binary '{"token":"11-TESTING-11-11"}'

I get a successful response:

{
"channelID": "MY_CHID",
"endpoint": "https://updates.push.services.mozilla.com/wpush/v1/HIDDEN",
"uaid": "MY_UAID",
"secret": "MY_SECRET"
}

But if I'm trying to send a message to the endpoint (with web-push), I'm getting the following error:

{
"code": 410,
"errno": 106,
"error": "",
"more_info": "http://autopush.readthedocs.io/en/latest/http.html#error-codes",
"message": "Request did not validate No such subscription"
}

Why would the endpoint be instantly invalid ?

@jrconlin
Copy link
Member

jrconlin commented Sep 1, 2017

First off, the "/registration" call you're making isn't really what you think it is. That's for mobile devices that use a known bridge system like GCM or APNS. (We currently allow an arbitrary string there for testing, but we really should limit to just the allowed bridge types in order to avoid this level of confusion.) The reason it's instantly 410 is because the system believes it needs to send a message to the "11-TESTING-11" bridge, which doesn't exist, fails, and returns the 410.

Now, getting back to the heart of your issue, I think you may misunderstand how WebPush works. WebPush is a way for an App on a browser to get messages. All the connection stuff is handled for you by the browser. MDN has documentation on the Push API, which describe how Apps get started. You can also look at serviceworke.rs for code samples and live demos.

As for the notification publishers (usually called the app servers), I've written a few articles that might be useful.

Does that help you?

@magne4000
Copy link
Author

magne4000 commented Sep 1, 2017

Thanks for the quick answer @jrconlin !

What I want to do in fact is what the browser does when it call subscribe, and is really difficult to find documentation about.

I want to be able to use WebPush inside a command line app (in Python or NodeJS for instance), or even a GUI App (what is important here is that I can't rely on the browser to do this for me).

So as far as I understand I need to able able to register to some Push backend, like GCM/FCM, but those 2 requires an InstanceID, which is a complete black box.

So I tried webpush through autopush but I think I didn't fully understand how this work (or even if this is possible) for my use case.

@jrconlin
Copy link
Member

jrconlin commented Sep 1, 2017

Sorry for the late reply.

So, you probably really don't want to do what you're trying. Technically, it's possible, but it's a significant hassle and definitely not supported.

Here's a rather long explanation that I hope helps. Technically, the WebPush RFC specifies how User Agents (e.g. Firefox, Chrome, Edge, etc.) can connect to the Push Service (autopush, GCM, MSNotifications, etc.). They're supposed to use HTTP2 with slightly modified frame usage. In reality, none of the WebPush providers actually do that. There's a lot of reasons for that, some legacy, some inertia, all of those reasons are pretty valid. Mostly because each User Agent only ever talks to its own Push Service. Chrome will never use our Push Service* and vice versa, nor will we ever use Microsoft's or Brave, or really, anyone else.

This is kind of a good thing because nothing is free and while Web Push doesn't cost you anything, we do pay a bill every month. We're fine paying the costs for all of our machines, but I don't think our accountants would be thrilled if we had to carry Chrome's userbase too.

Finally, WebPush is designed to be secure and easy for Apps, but there are FAR better protocols out there for connecting up devices. XMPP has a far richer protocol, PubSubHubBub deals with "broadcast" better, etc. Heck, if you're not connecting up a lot of devices or just want to play around a little, AWS Greengrass is a neat little messaging system for IoT stuff.

WebPush doesn't do broadcast, requires data encryption, a full time connection and a bunch of other things that may frustrate you more than help. May sound kinda odd coming from one of the folks that pushed hard for this, but I also realize that not all tools are good for all things. Sometimes you really want a hammer and that screwdriver just won't cut it.

(*Ok, technically we use google as a bridge, and they use our servers to handle some traffic, but that's weird and fuzzy and headache inducing.)

@magne4000
Copy link
Author

@jrconlin thanks for the detailed explanation !
Now I understand why I was struggling with this 😯
Really helpful to understand the current state of the WebPush ecosystem.

And thank you for the alternatives 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants