SherClockHolmes / webpush-go

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

Android Firefox returns a "413 Payload Too Large" #23

Closed JRaspass closed 5 years ago

JRaspass commented 5 years ago

Firstly, great work on this library, its working wonderfully for Chrome (Android/Desktop) and Firefox (Desktop), but I'm getting the following error when sending to Firefox on Android:

{"code": 413, "errno": 104, "error": "Payload Too Large", "more_info": "http://autopush.readthedocs.io/en/latest/http.html#error-codes", "message": "This message is intended for a constrained device and is limited to 3070 bytes. Converted buffer too long by 1366 bytes"}
andrewtet commented 5 years ago

@JRaspass running into the same issues and I was actually going to write up an issue about this last night. Seems like the issue is with the maxRecordLength and the pad function. The maxRecordLength in webpush-go is hard coded to 4096 and we pad every message to that length for security reasons, but for Firefox Mobile the max content length is 3070.

There's a PHP library for webpush that had similar issues and allows for a custom max content size to be passed in. @SherClockHolmes would you be okay with that solution?

PHP lib issue: https://github.com/web-push-libs/web-push-php/issues/62

PHP lib documentation of max content sizeL: https://github.com/web-push-libs/web-push-php#how-can-i-disable-or-customize-automatic-padding

P.S. It's been a while, but hope all is well @SherClockHolmes. This lib is great BTW

SherClockHolmes commented 5 years ago

@JRaspass @andrewtet Thanks for digging into the issue for me. I should have time for implementing this over the weekend.

ptman commented 2 years ago

For some reason RecordSize: 3070 didn't work for me with firefox android. I got a response back saying: "Final composed message payload too long for recipient: 4170 bytes. Please try a shorter message." No idea why that was larger than the limit set

RecordSize: 2048 seems to have worked