Git Product home page Git Product logo

apnagent's People

Contributors

avishaan avatar exploremqt avatar jonasrauber avatar logicalparadox avatar lslah avatar mkuprionis avatar mvdklip avatar nfroidure avatar nvh avatar phgrey avatar tassosd avatar vesln avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apnagent's Issues

Decoder Stream 11 not implemented

On our production server, I received this error causing a server restart:

Error uncaughtException: DecoderStream 11 not implemented.

Error: DecoderStream 11 not implemented.
 at Decoder._nudge (/home/code/live/agentXserver/node_modules/apnagent/node_modules/lotus/lib/lotus/decoder.js:138:18)
 at Buffers.g (events.js:199:16)
 at Buffers.emit (events.js:107:17)
 at Buffers.push (/home/code/live/agentXserver/node_modules/apnagent/node_modules/lotus/node_modules/bufs/lib/bufs.js:73:10)
 at Decoder._write (/home/code/live/agentXserver/node_modules/apnagent/node_modules/lotus/lib/lotus/decoder.js:154:15)
 at doWrite (_stream_writable.js:301:12)
 at writeOrBuffer (_stream_writable.js:288:5)
 at Decoder.Writable.write (_stream_writable.js:217:11)
 at TLSSocket.<anonymous> (/home/code/live/agentXserver/node_modules/apnagent/lib/apnagent/agent/live.js:159:18)
 at TLSSocket.emit (events.js:107:17)
 at readableAddChunk (_stream_readable.js:163:16)
 at TLSSocket.Readable.push (_stream_readable.js:126:10)
 at TCP.onread (net.js:538:20)

How can I catch it?

node agent/_header.js

Hi

I have a problem whit _header.js.

I have build an push server that works nice on my local developer env. But once I try to run it on server in DMZ ports opened are (2195,2196,80) if I run node agent/_header.js it doesn't connect and I dont get any error as well ?

this is from console on my Developer PC
D:\lpns>node agent/_header.js
apnagent [sandbox] gateway connected

if I do it the same way on the server I get nothing :(

PS C:\lpns\lpns> node agent/_header.js
PS C:\lpns\lpns>

What can be a issue ?

Sending push notifications in production environment not working

Hi,

I'm facing a strange problem where push notifications are working perfectly in the sandbox environment but not in production. We have verified that the .p12 certificate is working and can use the same certificate to send push notifications from another server application.

I'm using the node plugin for eclipse and stepping through the code and it appears that the notifications aren't being sent at all. The reason for this seems to be because the queue, to which the push tasks have been assigned, is paused - ie has its _paused field set to true.

However, no error is being thrown and as a result my node server thinks the push notifications have been sent, yet the devices never receive them.

It also appears that the exports.gatewayOptions function is being called repeatedly (I checked this to make sure it was picking up the correct host, in terms of sandbox and production) as a result of listOnTimeout() in timers.js, Agent._reconnect() in live.js, and Agent.connect() in live.js. For what it's worth, it is picking up the correct production URL, but the fact that this method is called repeatedly - every five seconds or so - made me wonder if there were somehow connection problems.

Can you help?

Thanks very much in advance.

Bob

Where is 'error mitigation' section

The documentation refers to an 'error mitigation' section but I don't see any detail related to that section. Specifically, what to do when a user unsubscribes to notifications. My assumption is there is a message:error event emitted on the agent but I don't see the documentation describing it in any level of detail.

sending push in bulk

This library looks promising, thank you.

One question I had in mind is what's the recommended way to send push in bulk, i.e. sending the same message to 100K subscribers at the same time, preferably in one call ?

Cheers,
Michael

Site Down

apnagent.qualiancy.com is current down and has been for days. any eta on when it will be back up?

TypeError: value is out of bounds

When I try to call apnagent.MockFeedback().unsub(token, new Date()), I got error "TypeError: value is out of bounds". What is the main reason for this error? Thanks.

Notification not received when device come from offline to online

Apnagent has default value for expires is 1d mean one day.

I am able to send notification to iOS device while device is online.

But, if i turn off internet connectivity & try to send notification it is not working.
I also try with setting agent.set('expires', '1d')

Below are the steps i am following :

  1. Make device offline by turn off all internet connectivity
  2. After that send push notification having expires value as 1 day
  3. After two minutes i make device online by turning internet on
  4. And i wait for 10 minute, still i am not getting any notification

createMessage - not catched error

I have this message on "createMessage"
"not cathed error:
[TypeError: undefined is not a function]"
but push sended and received well.
What is happened?

self.apnagent.createMessage()
.device(device)
.alert(message)
.badge(badge)
.sound('default')
.set('operation',operation)
.send(function (err) {
// handle apnagent custom errors
if (err) {
console.error('send push error:',err);
}
});
err - always "undefined"

sending MDM push notification to APNS

Hi,
I'm trying send a MDM push notification to the APNS server. My connection is successful and sending of notification is successful. Unfortunately APNS is not delivering the notification to the device instead it is reported in feedback service. Below is the code I used
var apnAgent = require('apnagent'),
fs = require('fs');
var agent = new apnAgent.Agent();

var tokenBuff = new Buffer("", 'base64'); //device Token
var cert = fs.readFileSync('./certificates/newCrt.pem');
var key = fs.readFileSync('./certificates/newKey.pem');
var tokenHex = tokenBuff.toString('hex');
var settings = {
"device": tokenHex,
"pushMagic":"push magic token",
"auth": {
"cert": cert,
"key": key
}

};
agent.gateway = 'gateway.push.apple.com'
agent.set(settings.auth);

agent.connect(function (err) {
// gracefully handle auth problems
if ((err != null) && (err.name === 'GatewayAuthorizationError')) {
console.log('Authentication Error: %s', err.message);
process.exit(1);
}
// handle any other err (not likely)
else if (err) {
throw err;
}
else {
console.log('connect to APNS');
}
});
/**

  • Listen for send errors
    • */

agent.on('message:error', function (err, msg) {
switch (err.name) {
case 'GatewayMessageError':
console.log('[emitted] gw notification error: %s', err.message);
if (err.code === 8) {
console.log(' > %s', msg.device().toString());

        }
        break;
    case 'MessageSerializationError':
        console.log('[emitted] serialization error: %s', err.message);
        break;
    default:
        console.log('[emitted] other error: %s', err.message);
        break;
}
//if (!err) {
//    console.log("Message is " + msg);
//}

});

var msg = agent.createMessage()
msg.device(tokenHex);
msg.set('mdm', settings.pushMagic);
msg.send(function (err) {
if (err) console.log('[cb] serialization error: %s', err.message);

});
The resultant Payload that is sent to server is using apnagent is
{"deviceToken":{"type":"Buffer","data":[]},"expiration":0,"identifier":0,"payload":{"mdm":"","aps":{}}}

Please help.

Thanks and regards
Venkatesh

Gateway sporadically stops sending notifications

It seems there's another bug after fixing #14 and #15 which is causing our agent to stop processing its queue.

Order of events:

  1. 18:23:22 - Last notification sent
  2. Queue begins piling up
  3. 18:24:16 - Cache cleaned out (30s TTL)
  4. 18:26:00 - Invalid token error received
  5. 18:26:03 - Gateway successfully reconnects
  6. Queue continues piling up. No more notifications have been sent since event 1 above.

I don't have any ideas as to why this is happening yet. Let me know if I can provide any more info that might be helpful.

Agents randomly stop reconnecting

We're having issues with agents not reconnecting sometimes after a message error. Here are the relevant log entries:

2014-08-04T20:03:58.212822+00:00 app[web.1]: apnagent:agent-live:web.1.14 [6ms] (gateway) data: 6 bytes
2014-08-04T20:03:58.214107+00:00 app[web.1]: apnagent:agent-live:web.1.14 [2ms] (gateway) disconnected - gateway.push.apple.com:2195
2014-08-04T20:03:58.214248+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (gateway) end
2014-08-04T20:03:58.214862+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (encoder) write: 28273
2014-08-04T20:03:58.215484+00:00 app[web.1]: apnagent:agent-live:web.1.14 [1ms] (queue) pause: not connected
2014-08-04T20:03:58.198696+00:00 app[web.1]: apnagent:agent-live:web.1.14 [1ms] (gateway) write: 28267
2014-08-04T20:03:58.199419+00:00 app[web.1]: apnagent:agent-live:web.1.14 [1ms] (cache) push: 28267
2014-08-04T20:03:58.200158+00:00 app[web.1]: apnagent:agent-live:web.1.14 [1ms] (encoder) write: 28268
2014-08-04T20:03:58.200419+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (gateway) write: 28268
2014-08-04T20:03:58.200600+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (cache) push: 28268
2014-08-04T20:03:58.200749+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (encoder) write: 28269
2014-08-04T20:03:58.201017+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (gateway) write: 28269
2014-08-04T20:03:58.201155+00:00 app[web.1]: apnagent:agent-live:web.1.14 [1ms] (cache) push: 28269
2014-08-04T20:03:58.201307+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (encoder) write: 28270
2014-08-04T20:03:58.201578+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (gateway) write: 28270
2014-08-04T20:03:58.201718+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (cache) push: 28270
2014-08-04T20:03:58.201865+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (encoder) write: 28271
2014-08-04T20:03:58.202116+00:00 app[web.1]: apnagent:agent-live:web.1.14 [1ms] (gateway) write: 28271
2014-08-04T20:03:58.202255+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (cache) push: 28271
2014-08-04T20:03:58.204973+00:00 app[web.1]: apnagent:agent-live:web.1.14 [2ms] (encoder) write: 28272
2014-08-04T20:03:58.205635+00:00 app[web.1]: apnagent:agent-live:web.1.14 [1ms] (gateway) write: 28272
2014-08-04T20:03:58.206080+00:00 app[web.1]: apnagent:agent-live:web.1.14 [1ms] (cache) push: 28272
2014-08-04T20:04:01.207280+00:00 app[web.1]: apnagent:agent-live:web.1.14 [2992ms] (cache) since: 28263
2014-08-04T20:04:01.217101+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (queue) push: 28271
2014-08-04T20:04:01.215785+00:00 app[web.1]: apnagent:agent-live:web.1.14 [8ms] (queue) push: 28264
2014-08-04T20:04:01.215850+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (queue) push: 28265
2014-08-04T20:04:01.215921+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (queue) push: 28266
2014-08-04T20:04:01.215987+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (queue) push: 28267
2014-08-04T20:04:01.216170+00:00 app[web.1]: apnagent:agent-live:web.1.14 [1ms] (queue) push: 28268
2014-08-04T20:04:01.216226+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (queue) push: 28269
2014-08-04T20:04:01.216590+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (queue) push: 28270
2014-08-04T20:04:01.217914+00:00 app[web.1]: apnagent:agent-live:web.1.14 [1ms] (queue) push: 28272
2014-08-04T20:04:01.217969+00:00 app[web.1]: apnagent:agent-live:web.1.14 [0ms] (gateway) reconnecting
2014-08-04T20:04:01.218187+00:00 app[web.1]: apnagent:agent-live:web.1.14 [1ms] (gateway) connecting - gateway.push.apple.com:2195

You can see that the gateway receives 6 bytes, then closes the gateway as it should. Next we see the queue pause, which is also expected. Then, two strange things happen. First, we see that after the queue has been paused, the gateway is still being written to, which shouldn't happen. The next strange thing is that although the reconnect attempt happens 3 seconds later, it never finishes connecting or throws an error. That's the last line in our log for that worker after it continued to run for another hour or so. I'm going to experiment with setTimeout and the timeout event on the tls socket to see if that event gets called in this case. Very strange stuff...

Edit: As you can see I added some additional logging, which you can find on my fork if it's of interest.

Consistent memory leaks

I'm seeing consistent memory leaks in our apnagent process. We're running two clusters of 4 express servers / apnagents and after a few hours they both exceed Heroku's memory cap of 512 MB. I can confirm that during the same period, the cache and queues are staying around the same size. I'm running with a 30s cache ttl.

screen shot 2014-08-08 at 12 13 46 pm
screen shot 2014-08-08 at 12 13 53 pm

I'm fairly confident that the leak isn't in our application code, since it's really a dead-simple express app that only interacts with apnagent. That said, I'm hoping to reproduce and trace the leak on my dev machine soon.

Suddenly not recieving notifications

I'm not retrieving any error messages, but after the server has been running for some time, notifications no longer shows up on the devices ?

When i restart the server everything works again :S

I'm running production mode, any thoughts ?

Seeking Maintainer

As it currently stands my professional interests have moved away from APN so I don't have as much time to maintain this as I used. Given its production value and importance I am open to allowing others to maintain this on a day-to-day basis.

If you or your company have committed to using apnagent and are interested in keeping this project moving, open a PR for an outstanding issue or new feature and mention your interest in maintaining so we can chat. Alternatively, feel free to email me through my GitHub profile. I will also provide access to any dependency which I have written for this module so you can keep things moving along.

APN agent connected coming false

Hi,
I was earlier able to send notifications using the below code.

agent
.set('cert file', join(__dirname, 'certfile.pem'))
.set('key file', join(__dirname, 'key.pem'))
.enable('sandbox');

agent
    .set('expires', '1d')
    .set('reconnect delay', '1s')
    .set('passphrase', 'password')
    .set('cache ttl', '30m');

agent.on('message:error', function (err, msg) {
    if(err) {
        console.log(err);
    }else{
        console.log(msg);
    }
});

agent.connect(function (err) {
    if (err && err.name === 'GatewayAuthorizationError') {
        console.log('Authentication Error: %s', err.message);
        process.exit(1);
    }

    // handle any other err (not likely)
    else if (err) {
        throw err;
    }

    // it worked!
    var env = agent.enabled('sandbox')
        ? 'sandbox'
        : 'production';

    console.log('apnagent [%s] gateway connected', env);
});

But suddenly, the agent has stopped connecting. eg when i console agent it shows :

{ _drip: { delimeter: ':', wildcard: true },
data: :11930 - connected: false,
data: :11930 - settings:
data: :11930 - { 'cache ttl': '30m',
data: :11930 - codec: 'enhanced',
data: : 11930 - }

It is not throwing an error neither is it sending messages. Any leads would be great. Thanks.

Can't use agent on openshift server

I'm developing a website , that should send push notifications to iOS devices. On my localhost apnagent works fine, but when I git push it to Openshift cloud I get the following errors in the terminal:

remote: Waiting for application port (8080) become available ...
remote: Application 'apnagent' failed to start (port 8080 not available)
remote: -------------------------
remote: Git Post-Receive Result: failure
remote: Activation status: failure
remote: Activation failed for the following gears:
remote: 55c3344c89f5cf720xxxxxxx (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/55c3344c89f5cf720xxxxxxx/nodejs
remote: #<IO:0x00000000f1c278>
remote: #<IO:0x00000000f1c200>
remote: )
remote: Deployment completed with status: failure
remote: postreceive failed
To ssh://[email protected]/~/git/apnagent.git/
   bbcf2a3..87exxxx  master -> master 

My package.json looks like this:

{
  "private": true,
  "name": "apnagent",
  "version": "0.0.0",
  "dependencies": {
    "apnagent": "1.0.x"
  },
  "engines": {
    "node": ">=0.10.22",
    "npm": ">=1.3.14"
  },
  "scripts": {
    "start": "node agent/_header.js"
  },
  "main": "agent/_header.js"
}

I think i should use somehow process.env.OPENSHIFT_NODEJS_PORT as port on the server, or something like this. I'm sure, I've done some configuration mistake since on my local machine everything works fine.

Queue is never restarted after SSL error

We're seeing intermittent SSL errors that produce the following log output:

2014-08-01T18:31:59.274859+00:00 app[web.2]: apnagent:agent-live [278ms] (gateway) error: 139718328477472:error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown:../deps/openssl/openssl/ssl/s3_pkt.c:1275:SSL alert number 46
2014-08-01T18:31:59.275014+00:00 app[web.2]: Gateway error [Error: 139718328477472:error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown:../deps/openssl/openssl/ssl/s3_pkt.c:1275:SSL alert number 46

No idea why we're seeing the error, given that the certs work fine 99% of the time. The main issue though is that the agent's queue is never restarted and/or a connection to the gateway is not made, so our application eventually runs out of memory from the queue backing up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.