SherClockHolmes / webpush-go

Web Push API Encryption with VAPID support.
MIT License
325 stars 68 forks source link

MS Edge rejects push messages #66

Open mrwonko opened 7 months ago

mrwonko commented 7 months ago

When I use the default Options.TTL of 0, the Windows Push Notification Service (WNS) rejects the request with status 400 and these headers:

X-Wns-Error-Description: Ttl value conflicts with X-WNS-Cache-Policy.
X-Wns-Notificationstatus: dropped
X-Wns-Status: dropped

This seems to be because webpush-go includes an explicit TTL: 0 header, which Microsoft interprets as "do not cache", but according to https://learn.microsoft.com/en-us/previous-versions/windows/apps/hh465435(v=win.10) the default X-WNS-Cache-Policy is to enable caching, hence the conflict.

I was able to work around this by providing a non-zero TTL, but maybe this can be solved on library level by only setting the TTL header if the value isn't 0?

mrwonko commented 7 months ago

Oh, Firefox rejects Push Messages without a TTL 😬

Then I guess we cannot omit the header for TTL=0. Maybe we should document that setting a non-0 TTL is strongly encouraged to maximize compatibility?

bsyo commented 5 months ago

I'm experiencing the same issue with my project.