-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Not receiving WebPush notifications on an endpoint to a PHP app #29716
Comments
What does the URL you're using look like? |
|
On your own server, do you see anything in the logs, sidekiq dashboard, or in the rails console via |
I found my subscription with the ruby console:
Can you tell me in what logs I can look to find the notifications? |
okay, and this is what I'd expect (I'd actually originally missed the |
You'd see these as dead jobs in Sidekiq, but I'm not 100% sure. |
I see one item in sidekiq/retries, a few minutes after I triggered a notification: Web::PushNotificationWorker | 7768, 48338 | OpenSSL::PKey::EC::Point::Error: EC_POINT_bn2point: invalid encoding Edit: And another one, with different arguments when mentioning my account. Could this be the error, preventing Mastodon from send the push notification? |
What is your In modern ruby, the decodedKey = Base64.urlsafe_decode64(key_p256dh)
group = OpenSSL::PKey::EC::Group.new('prime256v1')
client_public_key_bn = OpenSSL::BN.new(decodedKey, 2)
client_public_key = OpenSSL::PKey::EC::Point.new(group, client_public_key_bn) So if that throws with your What's your PHP code for creating the subscription? References: |
This is the $post_data I post to the instance subscriptions API (/api/v1/push/subscription).
|
Okay, so I can't look at how that key is generated, but my understanding was that the vapid key was on the sending side, not the receiving, and that the receiving side the key is for encryption. Did you look at the php webpush library linked from that article? It uses several methods from a Jose package around base64 encoding without padding. |
FWIW I did the same thing in PHP, set up endpoints to request and receive push notifications. I set up my keys and got a response with a push subscription ID. It seems my subscription response was truncated though and 100% positive my push handler endpoint is not receiving any traffic. Gonna try requesting a new subscription and see if I can reproduce it or not. But for @mbootsman I used PuTTY keygen to create the pem/pub files and grabbed them with this:
|
Does the .pub file have any headers? Is it already base64 url unsafe encoded? The web push subscription endpoint will accept invalid arguments. |
Ooo... I think my .pub file has headers. They both should, I didn't alter any PuTTY output after using the random keygen. And it gives key type options, I used the p265 option so maybe I don't need to encode. I didn't look at the header when I sent the request. Good to know it accepts my garbage tho. When I was reading docs, I read them as bad subscriptions might be due to instance admin issues. (love my admin) FWIW I really want these subscriptions in an effort to reduce load on instance servers, especially the smaller ones. I imagine when this process goes sideways, too many opt to poll servers every X seconds, which probably isn't ideal on both ends. In that aspect, optional home feed update notifications would be very welcome. |
Steps to reproduce the problem
Expected behaviour
PHP app on the endpoint should receive a POST request with the WebPush notification
Actual behaviour
Nothing
Detailed description
I have tested this on my own server toot.re (4.2.8) and mastodon.social (v4.3.0-nightly.2024-03-19)
Endpoint is publicly accessible. Checked this with various online tools.
Mastodon instance
No response
Mastodon version
No response
Technical details
If this is happening on your own Mastodon server, please fill out those:
Ruby version: (from
ruby --version
, eg. v3.1.2)ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux]
Node.js version: (from
node --version
, eg. v18.16.0)v16.20.2
The text was updated successfully, but these errors were encountered: