Closed flovilmart closed 2 years ago
Running into a similar issue sending push via REST on a hosted parse server:
curl -X POST \ -H "X-Parse-Application-Id: redacted" \ -H "X-Parse-Master-Key: redacted" \ -H "Content-Type: application/json" \ -d '{ "where": { "installationId": "redacted" }, "expiration_time":"2016-06-14T00:00:00Z", "data": {"alert":"redacted","sound":"default"} }' \ https://redacted.redacted.ext/parse/push
Comparison of the contents of _PushStatus json in MongoDB:
Sent via old parse.com: ... "expiry" : NumberLong(1465862400), "status" : "succeeded", ...
Sent via new hosted parse server ... "expiry" : 1465862400000.0, "status" : "failed", ...
It seems that converting the REST push "expiration_time":"2016-06-14T00:00:00Z" to the actual "expiry" epoch unix time gets 3 extra zero's added, and a .0 precision decimal.
Either a bug, or perhaps something related to dependency of international settings on the server side?
Seems related to https://github.com/parse-server-modules/parse-server-push-adapter/pull/14
When "expiration_time" is removed from the REST push, it works fine, push is sent and delivered.
In this case, parse server is running on Azure, region West Europe. Code pulled from Github using the Azure button on https://github.com/ParsePlatform/parse-server-example, around 11:00 AM CEST 2016-06-13.
I believe #14 does fix your issue, but the version of parse-server-push-adapter on npm (1.0.4 at time of writing) doesn't have that fix included. Thus, even the Github copy of ParsePlatform/parse-server-example wouldn't have #14 included, since they're separate packages.
Sadly, I don't know of an easy workaround short of pulling parse-server-push-adapter from Github and using npm link to override parser-server's package.json.
I'm gonna build a release soon
Initially Opened by @alistairbrightec as https://github.com/parseplatform/parse-server/issues/1959
When sending a push notification from cloud code to an iOS device, the cloud function returns successful however the server crashes with the following:
at flush (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:125:13) at runSingle (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:137:13) at /bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:1391:14 at Promise.promise.promiseDispatch (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:788:41) at Promise.apply (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:1165:26) at Connection. (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/lib/connection.js:287:8) at Connection.serviceBuffer (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/lib/connection.js:330:13) at Connection.transmitNotification (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/lib/connection.js:691:8) at Buffer.writeUInt32BE (buffer.js:923:5) at checkInt (buffer.js:830:11) TypeError: value is out of bounds ^ throw err; /bundle/node_modules/parse-server/lib/ParseServer.js:333
After digging into it, it only crashes if we include the line:
var oneWeekAway = new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000); ..... expiration_time: oneWeekAway,
The server I am using is one hosted by https://www.nodechef.com/parse-server and they requested that I posted this issue here
Steps to reproduce
Expected Results
No crash, send push notification, cloud function returns successfully
Actual Outcome
Server crashes and the cloud function returns successfully
Environment Setup
Logs/Trace
Unknown