parse-server: Some Push Notifications stuck in SENDING state

Issue Description

I’ve recently moved my Parse Server instance to Heroku. I’ve put my push logic in Cloud Code instead of using client push and I can send and receive push notifications.

My issue is that the status of the push object is stuck at SENDING in Parse Dashboard (“status”: “running” on the mongo object) when one of the pushes can’t be delivered to an installation.

Example: I send a push to a list of users, but some of them have an installation with no deviceToken configured. Those with a deviceToken receive the push, but the others don’t.

That’s an expected result, but the push status will stay forever in the SENDING state and I’m not sure if I should worry about it or not.

Note: The push status is changed correctly to SENT if all the Installations have a deviceToken and the number of push sent matches the number of push delivered. Also this behaviour did not occurred when I was using client push.

Steps to reproduce

Send a push to one or more installations with some correctly configured and some with no deviceToken.

Expected Results

Those with a deviceToken receive the push, but the others don’t. The push status change to something other than “running” even if some failed.

Actual Outcome

The push object is stuck forever at SENDING in Parse Dashboard (“status”: “running” on the mongo object) even is some notifications were delivered.

I’m not sure if this is a big issue and if I should worry about the server trying to send pushes indefinitely.

Environment Setup

  • Server

    • parse-server version : 2.3.5
    • Hardware: Standard-1x (512 MB)
    • Localhost or remote server?: Heroku
  • Database

    • MongoDB version: 3.0.14
    • Hardware: Shared Cluster
    • Localhost or remote server? mLab

Logs/Trace

Example: 3 pushes sent, 1 device received it, 2 failed because of missing deviceToken. Push object now in sending state forever.

2017-02-24T13:59:29.004277+00:00 app[web.1]: info: Ran cloud function sendPushToRecipients for user xVOydE7ugH with:
2017-02-24T13:59:29.004293+00:00 app[web.1]:   Input: {"recipients":["dpVQ9ZQypH","Vs3OADhHnS"],"data":{"alert":"test.","NTYPE":"NEW","badge":1,"sound":"default"},"appVersion":"1"}
2017-02-24T13:59:29.004295+00:00 app[web.1]:   Result: "Push Sent!" functionName=sendPushToRecipients, recipients=[dpVQ9ZQypH, Vs3OADhHnS], alert=test., NTYPE=NEW, badge=1, sound=default, appVersion=519, user=xVOydE7ugH

_PushStatus object

{
    "_id": "ZieiF3w31X",
    "pushTime": "2017-02-24T13:59:28.981Z",
    "query": "{\"currentProfile\":{\"$inQuery\":{\"where\":{\"objectId\":{\"$in\":[\"dpVQ9ZQypH\",\"Vs3OADhHnS\"]}},\"className\":\"Profile\"}},\"appVersion\":\"1\"}",
    "payload": "{\"alert\":\"test",\"NTYPE\":\"NEW\",\"badge\":1,\"sound\":\"default\"}",
    "source": "rest",
    "status": "running",
    "numSent": 1,
    "pushHash": "882c51079dfab452aed1f146fedb37a2",
    "_wperm": [],
    "_rperm": [],
    "_acl": {},
    "_created_at": {
        "$date": "2017-02-24T13:59:28.981Z"
    },
    "_updated_at": {
        "$date": "2017-02-24T13:59:29.066Z"
    },
    "count": 3,
    "sentPerType": {
        "ios": 1
    }
}

Cloud Code

Parse.Cloud.define("sendPushToRecipients", function(request, response) {
  var profileQuery = new Parse.Query("Profile");
  profileQuery.containedIn("objectId", request.params.recipients);
  var installationQuery = new Parse.Query(Parse.Installation);
  installationQuery.matchesQuery("currentProfile", profileQuery);
  installationQuery.equalTo("appVersion", request.params.appVersion);
  
  Parse.Push.send({
    expiration_interval:600,
    where: installationQuery,
     data: request.params.data
    }, {
      success: function() {
        response.success("Push Sent!");
      },
      error: function(error) {
        response.error("Push failed: " + error);
      },
      useMasterKey: true
    });
});

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 85 (69 by maintainers)

Most upvoted comments

@bjorno You can downgrade your Parse-server to version 2.3.1 and it will work except for a high volume of push messages (80k installations seems to work fine). Please, check the change log for more info.

You can downgrade your Parse-server by running the code: $ npm install parse-server@2.3.1

@flovilmart I’m running my own version of the parse-server-example. To give you an example of what I’ve done you can check the forked version where I’ve updated the parse-server-example to include a config file in json format and a way to run multiple instances of Parse-Server on different ports.

Regarding the push issue, I think the setup function is not being called on the adapter.

@iOSassou Do not worry that the push messages arrive without problem and does not affect the performance at all, it is only an error to update the status.