web-push-php: Firefox for Android doesn't deliver every push notifications

NOTE: Please test in a least two browsers (i.e. Chrome and Firefox). This helps with diagnosing problems quicker.

Please confirm the following:

  • I have read the README entirely
  • I have verified in the issues that my problem hasn’t already been resolved

Setup

Please provide the following details, the more info you can provide the better.

  • Operating System: <debian> PHP 5.6.30
  • web-push-php Version: latest as of this date

Please check that you have installed and enabled these PHP extensions :

YUP

Please select any browsers that you are experiencing problems with:

  • Firefox for Mobile 54.0.1 - android 4.2

Problem

firefox for android doesn’t work with default setting. Works when $webPush->setAutomaticPadding(false); is set .

Errors with the default setting, Haven’t checked other values, but the default fails with a 410 error

[“message”]=> string(427) "Client error: POST https://updates.push.services.mozilla.com/wpush/v2/gAAAAA..........M-yXA resulted in a 410 Gone response: {“code”: 410, “errno”: 999, “error”: “”, “more_info”: “http://autopush.readthedocs.io/en/latest/http.html#error-codes”,

Expected

to return true.

Features Used

  • VAPID Support

Example / Reproduce Case

function webPush_Register() { $authPush = array( ‘VAPID’ => array( ‘subject’ => ‘https://coinvalue.me’, ‘publicKey’ => PUBLICKEY, ‘privateKey’ => PRIVVATEKEY ), ); $webPush = new WebPush($authPush); // $webPush->setAutomaticPadding(false); // disable automatic padding return $webPush; }

Other

Thanks for the library 😃

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 26 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Padding is a cryptographic technique to obscure the content of what’s being sent. As a super simple example, if I were to send you a message asking if you wanted to go to “the park”, “the cafe” or “the monkey knife fighting pit” and you sent back a string that was around 30 characters long, I might guess you have a preference for simian slicing even if I can’t read the message directly.

Ideally padding should make the message length as consistent as possible. One way to do that is to use padding that ensures that messages are the maximum allowable length, since good padding should trim to just fill in everything between the actual message length and the size you’re specifying.

Where things get complicated is in the fact that Autopush (the server we run to handle web push) has to talk to the various mobile push networks in order to deliver the messages (e.g. Google’s Fire Cloud Messaging (FCM)). These have their own limits on message size and format. Cryptography increases the size of the message, as does Base64 encoding (which is required by FCM), as well as the envelope we have to wrap things in for delivery. All of those impact the total size you can send. Autopush does try to help and returns a 413 error if it thinks the message might be too big.

So, what are viable solutions?

  1. Check to make sure that the padding function is doing the right thing. Padded messages should all come out about the same length so an encoded “hello” should be about the same length as “greetings and felicitations to all who read this”.

  2. It may just be that 2847 is the correct padding length and that’s the default that should be used for body content. As an added bonus, it means that the max message size you send out to android clients will be a bit short of that limit as well (2832 or so, see above for reasons).

Just wanted to let you know that the issue as described in the first comment seems to still exist. If I can be of any assistance in helping to debug this @jrconlin or @Minishlink then happy to help.

If the notification is pushed to a Mozilla endpoint subscribed to via macOS, it works fine. If it’s a Mozilla endpoint and Android (7) then it fails with a 410 gone err 999 message.

We’re working around it by disabling automatic padding for any Mozilla endpoint right now which makes it work for Android:

$webPush->setAutomaticPadding(0);

Which is ok, but obviously we’d rather keep the padding if possible.

Bump. This issue is still happening. Firefox 68.1 for Android I suppose it is because of this https://github.com/mozilla-services/autopush/issues/748

@jrconlin sorry only just had a chance to test this.

Looks like a padding value of 2848 is when Firefox stops receiving the notifications. 2847 is fine in my testing though of course I appreciate you might want to trim it down a bit further.

After all that, just realised that my version of Firefox is outdated so I’d better test again in case anything has changed on their side…

EDIT: Yep, 2848 still breaks it.

Going to reopen this to try a patch.