Open meewash-p opened 3 months ago
Ah, looks like there are several headers that they want. I'm half tempted to put these under an option flag just in case they might mess up Apple or Google for some stupid reason.
(I'll also note that pywebpush
exposes a parameter for headers
for things like this. It does mean that the calling code needs to know the TTL
is 0, so it applies the correct caching header, but it's a reasonable work-around)
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.
I'm going to update it to include an error to check for the X-WNS-Type
header if --wns
is specified as a flag.
My code now works after adding only a ttl value after seeing the npm module has a large default value. Looking at the MS doc mentioned earlier many of the headers are optional.
Right, X-WNS-Type
is marked as a required field (as either tile
, toast
, badge
or raw
, with the Content-Type
set to text/xml
except if raw
where it's set to application/octet-stream
.)
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. 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.
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 https://github.com/web-push-libs/pywebpush/issues/162#issuecomment-2067005684, 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: