parse community node-apn fork - send job hangs

352 views Asked by At

We are using the parse fork of node-apn lib ( https://github.com/parse-community/node-apn ) - we switched a year ago to this fork because our actual problem - but now its back.

We are sending around 1.000.000 notifications, separated to different sub-jobs and some of them just hang while sending to apple, after calling apnProvider.send() ... we don't get an answer/callback.

The problem was happen often end of last year and the whole year it worked fine - and beginning last weekend the problem came back - without any change on our side :-( from 40 processes 1 or 2 just break up there work.

We implemented a workaround, a watchdog that sees the hanging process after 30 seconds and stops it, but this is a bad solution. I wanted to ask if someone has any idears to fix it or to find out the real reason. I dont get an error event or something.

We tested different nodejs versions and working on ubuntu server - also tested differend versions.

best regards.

Code parts:

Initialisation:

var options = { production: apnsProduction };
options.token = {key: apnsKey, keyId: apnsKeyId, teamId: apnsTeamId };
apnProvider = new apn.Provider(options);

Watching Events:

apnProvider.on("transmissionError", function(errCode, notification, device) {
      console.log(...);
});

apnProvider.on("timeout", function () {
   console.log(...);
});

apnProvider.on("disconnected", function() {
   console.log(...);
});

apnProvider.on("socketError", function(err){
   console.log(err);
});

apnProvider.on("goaway", function(err){
   console.log(err);
});

Then we have the receivers in mysql, so i do a select and collect 100 receivers in an array and send the message to them:

apnProvider.send(message, arrReciver).then( (result) => {

      result.sent.forEach( (token) => {
         transmittedCnt++;
      });

      result.failed.forEach( (failure) => {
         errorCnt++;

         if (failure.error) // A transport-level error occurred (e.g. network problem)
         {
             console.log(...) // some log output ...
         }
         else
         {
            db.deletePushDev("ios", failure.device, "send error " + failure.status + " - " + util.inspect(failure.response));  
         }
      });

      cntSendFunctionsRunning--;
      callback();
   }).catch((result) => {
      console.log(result);
   });

the callback() ... does continue the select fetch for the next 100 devices ... Hope this is clear enought - I cannot provide the whole code here.

1

There are 1 answers

0
trx On BEST ANSWER

The issue ist now handled in the new version 4.0.0 of the node-apn fork from the parse community. New version handles the timeout of the http2 connections.

Issue: https://github.com/parse-community/node-apn/issues/24