404 error sending push with web-push
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 20/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, node.js
- Área
- backend, networking
Línea de trabajo
Start with src/web-push-lib.js around line 317 and the sendNotification call, then reproduce the supplied Android endpoint with the shown subscription and configuration. Done means establishing whether the 404 is caused by endpoint handling or by the mobile subscription setup, with a documented reproduction or a focused library change.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Setup
Operating System: OS X 10.13.6
Node Version: 8+
web-push Version: ^3.3.3
Browsers
- Chrome
- Firefox
- [ X ] Brave for Android
- [ X ] Firefox for Android
- Opera for Android
- Samsung Internet Browser
- Other
Tested with
FF dev edition: 69.0b13
Firefox for Android: latest
Chromium: 75.0.3770.80
Brave: 1.0.92 chromium 73.0.3683
Problem
Failing to receive push notifications on mobile browsers but am 100% successful when it comes to desktop chrome and desktop Firefox. Mobile Firefox times out at the call to retrieve the subscription, not sure what's uo there. Error below is what I see in my server logs trying to send to Brave (chrome) on Android.
Expected
Expecting to receive push notifications in mobile browsers.
Features Used
- [ X ] VAPID Support
- [ X ] GCM API Key
- [ X ] Sending with Payload
Example / Reproduce Case
sendPush is passed a subscription:
{"endpoint":"https://android.googleapis.com/gcm/send/APA91bFUe9TBIeqs9WrkcBhVa4rXfl5O2kiuzZwO6W-pkEY8SqOfvWydppOObv4ujXsqrn0w3bVIt8PUz5W2I9Yd2oAc91z3UUVi9ISd3p51-87S0Qdi6ZUYgGWTXk4Ut3I0NGbC-WtG","expirationTime":null,"keys":{"p256dh":"BBv_KznIPvyOvLcSFQC0lrgUfH1O-RznjkL9tlZKJp7nY6P5gjC21Xh3aUH_3sqNc71rPjDzUI5aL8bzu6vYp_c","auth":"FvPaHA_0pXkbXUbWpvFMZQ"}}
and a payload which is just a string. Server side code:
const webPush = require("web-push")
webPush.setGCMAPIKey(process.env.GCMAPIKey)
webPush.setVapidDetails(
'mailto:[email protected]',
process.env.VAPID_PUBLIC_KEY,
process.env.VAPID_PRIVATE_KEY
)
module.exports = {
sendPush: function (subscription, payload, options = {}) {
try {
if (!process.env.VAPID_PUBLIC_KEY || !process.env.VAPID_PRIVATE_KEY) {
console.log("You must set the VAPID_PUBLIC_KEY and VAPID_PRIVATE_KEY "+
"environment variables. You can use the following ones:")
console.log(webPush.generateVAPIDKeys())
return
}
return webPush.sendNotification(subscription, payload)
.then(function(data) {
return data
})
} catch (error) {
console.error(error)
return error
}
}
}
As for the front end, I am using:
const applicationServerKey = "longstring"
const subscribeOptions = {
userVisibleOnly: true,
applicationServerKey: urlBase64ToUint8Array(applicationServerKey)
}
return navigator.serviceWorker.ready.then(async (swreg) => {
let subscription = await swreg.pushManager.getSubscription()
let isSubscribed = !(subscription === null)
if (!isSubscribed) {
return swRegistration.pushManager.subscribe(subscribeOptions).then(subscription => ...)
}
// and either way send subscription to the server for use later
}
I have tried with a server key I got from google FCM console with the matching sender ID in my manifest, have tried without the sender ID as well. The exact same code works perfectly on desktop. I believe I'm just really mixed up when it comes to VAPID GCM/FCM and how to navigate all of that, I don't understand why code that works perfectly on desktop triggers to many errors on mobile browsers:
Firefox mobile never makes it passed here: await swreg.pushManager.getSubscription(), it just times out I really don't understand that one.
Brave returns the error detailed below, 404 from webPush.sendNotification call.
Other
Error returned from this call is:
Error sending push message:
{ WebPushError: Received unexpected response code
at IncomingMessage.<anonymous> (/Users/new/.nvm/versions/node/v10.0.0/lib/node_modules/web-push/src/web-push-lib.js:317:20)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1091:14)
at process._tickCallback (internal/process/next_tick.js:174:19)
name: 'WebPushError',
message: 'Received unexpected response code',
statusCode: 404,
headers:
{ 'content-type': 'text/plain; charset=utf-8',
'x-content-type-options': 'nosniff',
'x-frame-options': 'SAMEORIGIN',
'x-xss-protection': '0',
date: 'Tue, 13 Aug 2019 20:38:49 GMT',
'content-length': '135',
'alt-svc': 'quic=":443"; ma=2592000; v="46,43,39"',
connection: 'close' },
body: 'A valid push subscription endpoint should be specified in the URL as such: https://fcm.googleapis.com/wp/dHIoDxE7Hdg:APA91bH1Zj0kNa...\n',
endpoint: 'https://android.googleapis.com/gcm/send/APA91bES_PMZ9P6fqOHYoIc059yEcjRT_5x32SptsrUx8Gbw3FmHaWaJ1bvb-kj1Updw5T9ChWlg9r5ihkmp5XimhmmKEbPKMm6coXo14YJMxqkVCMYrpBdR7X1ZWEmh87O_ZX7AzunN' }
- Lenguaje dominante
- JavaScript
- Estrellas
- 3.6k
- Forks
- 328
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de web-push-libs/web-push
-
No Releases Since 3 Years AgoAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
web-push-libs/web-push#978 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
web-push-libs/web-push#977 ·
-
Does it can be use in China?Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
web-push-libs/web-push#942 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
web-push-libs/web-push#940 · 1 reacción ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
web-push-libs/web-push#939 · 3 comentarios ·
Todos los issues de web-push-libs/web-push
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
solana-foundation/solana-web3.js#4015 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
gramps-project/gramps-web#1604 ·
Los mantenedores suelen responder en 1 día
-
enhancement good first issue hacktoberfest help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
BinaryBaconLabs/todo-app#18 ·
-
Cache airport lookupsAbiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
sutantyo/flight-watch#32 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día