-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
400 Bad Request when using Windows Push Notification Services (WNS) endpoint #162
Comments
Ah, looks like there are several headers that they want. |
(I'll also note that |
Microsoft has introduced [extra header](https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/push-request-response-headers#request-parameters) requirements for incoming push messages. I kind of want to avoid adding a lot of system specific smarts to pywebpush, mostly because that's an endless road of feature creep. The preferred way to handle this would be to include the extra, call specific headers in the `webpush(..., headers=dict(...))` argument. Closes #162
I have been trying to make this work (web push to Edge from a Flask app using this library) and was about to give up on Edge until I successfully sent a web push to Edge using the Node web-push library from the command line. After seeing the notes in the issue, I took a look in the Node library code for wns headers and found none. Just FYI |
Ah, thanks for the bump on this. I was waiting for a review. Apparently from Godot. |
My code now works after adding only a ttl value after seeing the npm module has a large default value. |
Right, I can do some simple checks to make sure folk are sending the right format, but this is all fairly non-standard and a lot of extra work. I'm also just tempted to add some content to the README talking about how non-standard this is and what extra stuff you need to do to send notification messages to Windows computers. |
Ok, so here's the deal. I'm not going to add any special handling for WNS. In fact, I'm going to take this opportunity to drop the special handling we were doing for GCM/FCM, since that's going away in less than 2 months and has been obsolete for nearly a year now. If you want to use this library with WNS, you have to add the headers yourself, since they're subject to change anyway. I've added a note in the README for what you'll need to do. |
Sounds right to me. Anything beyond adding a note for WNS - add TTL and
life is good other than that add headers, see this doc - seems unnecessary.
…On Fri, Apr 19, 2024 at 12:35 PM JR Conlin ***@***.***> wrote:
Ok, so here's the deal.
I'm not going to add any special handling for WNS. In fact, I'm going to
take this opportunity to drop the special handling we were doing for
GCM/FCM, since that's going away in less than 2 months and has been
obsolete for nearly a year now.
If you want to use this library with WNS, you have to add the headers
yourself, since they're subject to change anyway. I've added a note in the
README for what you'll need to do.
If you were using this to talk to GCM/FCM directly and not using Web Push,
this is your wake-up call that you really, really need to stop doing that.
—
Reply to this email directly, view it on GitHub
<#162 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACM4WELXNTKXXGU4PNSHJLY6FIUTAVCNFSM6AAAAABEFE2GQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRXGAYDKNRYGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hi,
I've encountered an issue when sending a push to the endpoint from WNS (MS Edge browser). Their service is responding with 400 Bad Request with no body.
After quick debugging, there was an error reason in response headers:
{
"Content-Length": "0",
"mise-correlation-id": "927f3b90-c2cf-4649-97a9-94330058c16d",
"X-WNS-ERROR-DESCRIPTION": "Ttl value conflicts with X-WNS-Cache-Policy.",
"X-WNS-STATUS": "dropped",
"X-WNS-NOTIFICATIONSTATUS": "dropped",
"Date": "Mon, 04 Mar 2024 12:24:23 GMT"
}
Turns out, WNS requires X-WNS-Cache-Policy request header set to either cache or no-cache depending on a ttl value.
Adding the header helps. Also, I'd suggest including headers in the exception message. :)
If you have that issue with WNS add x-wns-cache-policy header (if using ttl than x-wns-cache-policy: cache) in your code, e.g.:
I'd do sth like this:
The text was updated successfully, but these errors were encountered: