parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.83k stars 4.77k forks source link

VError: stream ended unexpectedly when trying to deliver a PUSH notification on iOS #6380

Closed patrickferreira closed 4 years ago

patrickferreira commented 4 years ago

Issue Description

I have an iOS app, and every device registers its token when the user registers for remote notifications, like so: let installation = PFInstallation.current() installation?.setDeviceTokenFrom(deviceToken) installation?.saveInBackground()

For some reason, I am able to send notifications to all the users that were previously saved in my mongo database. It still works for all the existing ones.

However, for every new user that I now add in my Parse server database, PUSH notifications don't work. I am trying to send a PUSH notification to ONE device, and it just fails every time.

I have around 10K users in my database, and it has always worked just fine before, so I am not sure why it stopped working for new users... I discovered that bug on parse-server 3.9.0, tried updating to 3.10.0, but it didn't fix anything.

Let me know if I can provide any further info.

Push Configuration

push: { ios: [ { pfx: 'XXXXXXXXXXXX.p12', topic: 'XXXXXXXXXXX', production: false }, { pfx: 'XXXXXXXXXX.p12', topic: 'XXXXXXXXX', production: true } ] }

Environment Setup

Logs/Trace

0|Pilot (p | verbose: REQUEST for [GET] /parse/classes/_Installation: { 0|Pilot (p | "where": { 0|Pilot (p | "appId": "Y215ZD6AE4", 0|Pilot (p | "serverNotifications": true 0|Pilot (p | }, 0|Pilot (p | "limit": 0, 0|Pilot (p | "count": 1 0|Pilot (p | } {"method":"GET","url":"/parse/classes/_Installation","headers":{"user-agent":"node-XMLHttpRequest, Parse/js2.11.0 (NodeJS 8.17.0)","accept":"*/*","content-type":"text/plain","host":"localhost:1337","content-length":"296","connection":"close"},"body":{"where":{"appId":"XXXXXXXXXX","serverNotifications":true},"limit":0,"count":1}} 0|Pilot (p | verbose: RESPONSE from [GET] /parse/classes/_Installation: { 0|Pilot (p | "response": { 0|Pilot (p | "results": [], 0|Pilot (p | "count": 1 0|Pilot (p | } 0|Pilot (p | } {"result":{"response":{"results":[],"count":1}}} 0|Pilot (p | verbose: REQUEST for [POST] /parse/push: { 0|Pilot (p | "where": { 0|Pilot (p | "appId": "XXXXXXXXXX", 0|Pilot (p | "serverNotifications": true 0|Pilot (p | }, 0|Pilot (p | "data": { 0|Pilot (p | "alert": { 0|Pilot (p | "title": "XXXXXXXXXX", 0|Pilot (p | "body": "XXXXXXXXXX" 0|Pilot (p | }, 0|Pilot (p | "sound": "default" 0|Pilot (p | } 0|Pilot (p | } {"method":"POST","url":"/parse/push","headers":{"user-agent":"node-XMLHttpRequest, Parse/js2.11.0 (NodeJS 8.17.0)","accept":"*/*","content-type":"text/plain","host":"localhost:1337","content-length":"337","connection":"close"},"body":{"where":{"appId":"XXXXXXXXXX","serverNotifications":true},"data":{"alert":{"title":"zdazdzadb","body":"azdzadzadz"},"sound":"default"}}} 0|Pilot (p | verbose: RESPONSE from [POST] /parse/push: { 0|Pilot (p | "headers": { 0|Pilot (p | "X-Parse-Push-Status-Id": "XXXXXXXXXX" 0|Pilot (p | }, 0|Pilot (p | "response": { 0|Pilot (p | "result": true 0|Pilot (p | } 0|Pilot (p | } {"result":{"headers":{"X-Parse-Push-Status-Id":"XXXXXXXXXX"},"response":{"result":true}}} 0|Pilot (p | OK 0|Pilot (p | verbose: _PushStatus XXXXXXXXXX: sending push to installations with %d batches 0|Pilot (p | verbose: Sending push to 1 0|Pilot (p | ERR! 0|Pilot (p | 0|Pilot (p | parse-server-push-adapter APNS 0|Pilot (p | VError: stream ended unexpectedly 0|Pilot (p | ERR! 0|Pilot (p | 0|Pilot (p | parse-server-push-adapter APNS 0|Pilot (p | at ClientHttp2Stream.request.on (/home/patrick/parse-server-pilot/node_modules/@parse/node-apn/lib/client.js:137:23) 0|Pilot (p | ERR! 0|Pilot (p | 0|Pilot (p | parse-server-push-adapter APNS 0|Pilot (p | at emitNone (events.js:111:20) 0|Pilot (p | ERR! parse-server-push-adapter APNS at ClientHttp2Stream.emit (events.js:208:7) 0|Pilot (p | ERR! parse-server-push-adapter APNS at endReadableNT (_stream_readable.js:1064:12) 0|Pilot (p | ERR! parse-server-push-adapter APNS at _combinedTickCallback (internal/process/next_tick.js:139:11) 0|Pilot (p | ERR! parse-server-push-adapter APNS at process._tickDomainCallback (internal/process/next_tick.js:219:9) 0|Pilot (p | ERR! parse-server-push-adapter APNS APNS error transmitting to device %s with error %s 16c51113321dc53f076e6f1059c6f2ed4dd73c8a816bc5d0e3cd9e2f90a4f6bf { VError: stream ended unexpectedly 0|Pilot (p | ERR! parse-server-push-adapter APNS at ClientHttp2Stream.request.on (/home/patrick/parse-server-pilot/node_modules/@parse/node-apn/lib/client.js:137:23) 0|Pilot (p | ERR! parse-server-push-adapter APNS at emitNone (events.js:111:20) 0|Pilot (p | ERR! parse-server-push-adapter APNS at ClientHttp2Stream.emit (events.js:208:7) 0|Pilot (p | ERR! parse-server-push-adapter APNS at endReadableNT (_stream_readable.js:1064:12) 0|Pilot (p | ERR! parse-server-push-adapter APNS at _combinedTickCallback (internal/process/next_tick.js:139:11) 0|Pilot (p | ERR! parse-server-push-adapter APNS at process._tickDomainCallback (internal/process/next_tick.js:219:9) 0|Pilot (p | ERR! parse-server-push-adapter APNS jse_shortmsg: 'stream ended unexpectedly', 0|Pilot (p | ERR! parse-server-push-adapter APNS jse_info: {}, 0|Pilot (p | ERR! parse-server-push-adapter APNS message: 'stream ended unexpectedly', 0|Pilot (p | ERR! parse-server-push-adapter APNS stack: 'VError: stream ended unexpectedly\n at ClientHttp2Stream.request.on (/home/patrick/parse-server-pilot/node_modules/@parse/node-apn/lib/client.js:137:23)\n at emitNone (events.js:111:20)\n at ClientHttp2Stream.emit (events.js:208:7)\n at endReadableNT (_stream_readable.js:1064:12)\n at _combinedTickCallback (internal/process/next_tick.js:139:11)\n at process._tickDomainCallback (internal/process/next_tick.js:219:9)' }

patrickferreira commented 4 years ago

Found the issue. 2 issues actually:

If anyone else is having trouble debugging this kind of error, this utility was helpful: https://github.com/onmyway133/PushNotifications