Code Monkey home page Code Monkey logo

node-apn's People

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  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

node-apn's Issues

Connection lost. Won't reconnect

I have node-apn running and if the internet connection is lost and reconnected, the apn notifications no longer get sent. Is there a way to reconnect when this happens?

Thanks.

Miss ability to add custom CA

Hello,

I'm going through a very inconvenient problem after the migration to the production environment. After some investigations, I discovered that the entrust_2048_ca.cer needed wasn't set, and node is not able to find it on the current server.

It can be great if you could add the possibility to set the ca inside the option object given to the connection.

In summary just add a options['ca'] && (socketOptions['ca'] = options['ca']) before the connection.

Maybe there is a way to embed this certificate in the cert.pem, but I tried some stuff, and I wasn't able to make it work.

Thank you if you have any idea to fix this problem.

ENOENT error code explaination

Is there detail for the following error:

{ [Error: ENOENT, open 'cert.pem'] errno: 34, code: 'ENOENT', path: 'cert.pem' }

Cannot read property 'authorized' of undefined

I'm getting the following exception when i send a PUSH to an invalidToken (thats the ERR: 8 coming back from the callback)

the exception is fatal and kill my entire application.

2011-09-16T00:59:12+00:00 app[web.1]: ERR: 8
2011-09-16T00:59:12+00:00 app[web.1]: Response: [object Object]
2011-09-16T00:59:12+00:00 app[web.1]:
2011-09-16T00:59:12+00:00 app[web.1]: /app/node_modules/apn/lib/apn.js:51
2011-09-16T00:59:12+00:00 app[web.1]: if(!self.socket.authorized) {
2011-09-16T00:59:12+00:00 app[web.1]: ^
2011-09-16T00:59:12+00:00 app[web.1]: TypeError: Cannot read property 'authorized' of undefined
2011-09-16T00:59:12+00:00 app[web.1]: at /app/node_modules/apn/lib/apn.js:51:20
2011-09-16T00:59:12+00:00 app[web.1]: at SecurePair. (tls.js:868:13)
2011-09-16T00:59:12+00:00 app[web.1]: at SecurePair.emit (events.js:61:17)
2011-09-16T00:59:12+00:00 app[web.1]: at SecurePair._maybeInitFinished (tls.js:593:10)
2011-09-16T00:59:12+00:00 app[web.1]: at CleartextStream._pull (tls.js:355:15)
2011-09-16T00:59:12+00:00 app[web.1]: at SecurePair._cycle (tls.js:558:20)
2011-09-16T00:59:12+00:00 app[web.1]: at EncryptedStream.write (tls.js:97:13)
2011-09-16T00:59:12+00:00 app[web.1]: at Socket.ondata (stream.js:40:26)
2011-09-16T00:59:12+00:00 app[web.1]: at Socket.emit (events.js:64:17)
2011-09-16T00:59:12+00:00 app[web.1]: at Socket._onReadable (net.js:676:14)

TypeError: Cannot read property 'authorized' of undefined

I'm seeing this error periodically:

/usr/local/lib/node_modules/apn/lib/apn.js:50
self.socket.pair.on('secure', function () { if(!self.socket.authorized) { th
^
TypeError: Cannot read property 'authorized' of undefined
at SecurePair. (/usr/local/lib/node_modules/apn/lib/apn.js:50:62)
at SecurePair.emit (events.js:81:20)
at SecurePair._maybeInitFinished (tls.js:581:10)
at CleartextStream._pull (tls.js:350:15)
at SecurePair._cycle (tls.js:548:20)
at EncryptedStream.write (tls.js:94:13)
at Socket.ondata (stream.js:36:26)
at Socket.emit (events.js:64:17)
at Socket._onReadable (net.js:673:14)
at IOWatcher.onReadable as callback

I believe this occurs when the APN gateway is unreachable and the fix is to simply check the socket.

var startSocket = function () {
    self.socket = tls.connect(options['port'], options['gateway'], socketOptions);
    if (self.socket !== undefined) {
    self.socket.pair.on('secure', function () { if(!self.socket.authorized) { throw self.socket.authorizationError } while(offlineCache.length) { self.socket.write(offlineCache.shift()); } });
    self.socket.on('data', function(data) { handleTransmissionError(data); });
    self.socket.on('error', function(data) {self.socket.removeAllListeners(); self.socket = undefined; });
    self.socket.once('end', function () {  });
    self.socket.once('close', function () { self.socket.removeAllListeners(); self.socket = undefined; });
    }
}

The offline cache will get populated and the note sent later.

errorCallback() & Feedback

Hi, i'm using your great work for my project. I'm new in JavaScript development.

I've created a function called myErrorCallback(errorCode, note), and insert it on the connection options to APNS. Am I doing wrong ? If ok, I wan't to send a message to the client who has sent this notification through the RESPONSE http server variable. How can I do that ?

For the feedback, I want to add a callback to remove to my database these devices token. How can I do that ?

Thank you

TypeError: Object #<Object> has no method 'request'

while running feedback, I've received the following exception:

feedback_test.js/node_modules/apn/lib/apn.js:410
self.request();
^
TypeError: Object # has no method 'request'
at Timer. (/Users/minorblend/Dev/Toby.js/node_modules/apn/lib/apn.js:410:9)
at Timer.ontimeout (timers.js:223:14)

my code is quite simple and I can't find out what's wrong.

var apn = require('apn');

function apnFeedback(time, device_token) {
  console.log(new Date(time * 1000) + ': ' + device_token);
}
apn.Feedback({ cert: './cert_file.pem',
               key: './key_file.pem',
               address: 'feedback.push.apple.com',
               port: 2196,
               feedback: apnFeedback,
               interval: 5 });

node 0.4.0+ compatibility

As of 0.4.0 the TLS API which node-apn depends on has changed. The old methods have been deprecated and node-apn must be reworked to utilise the new system.

Creating Device Object

Hi,

I have a token as below and I'm trying to create a Device object
"d5c1e588 9d336101 fb74bdea ae64b61e 037cc958 f27d50dd ed9c91da 9d6c5e53"

var myDevice = new apns.Device("c1d5e5889d336101fb74bdeaae64b61e037cc958f27d50dded9c91da9d6c5e53d78", ascii=false);
var note = new apns.Notification();

note.badge = 3;
note.alert = "You have a new message";
note.device = myDevice;
apnsConnection.sendNotification(note);

And I keep getting:
TypeError: Object c1d5e5889d336101fb74bdeaae64b61e037cc958f27d50dded9c91da9d6c5e53d78 has no method 'copy'

Thanks,

Provide cache adjustment info

If a notification error occurs and it is not found the in the cache, it should be possible to estimate how many were missed based on the ID. Notify user of the difference so the cache value can be adjusted appropriately for their throughput. Perhaps even adjust it automatically.

More Error Handling

To whom it may concern

I tried the library already. It is a very good library however I noticed something. When I provided the wrong cert and key or wrong path for them, there is no error message or any way to tell me what went wrong.

There should be error handling at some levels like, getting the correct cert and key, connected to the APN server, delivered the message. Even when the message got delivered successfully, there should be a callback to inform that.

Anyway, it is a awesome library.

Thanks

apn-test.js fails with InvalidToken error

When running the provided apn-test.js (and when implementing the library in my own code) the error response is always InvalidToken. Using the pushdev-cert.pem and pushdev.pem appears to just do nothing.

errorCallback isn't fired?

In the following code the errorCallback isn't triggered. node-apn installed via npm, v1.0.1, node v0.2.5.

var sys = require('sys'),
fs = require('fs'),
apns = require('apn');

var options = {
  cert: 'cert.pem' 
  , key:  'key.pem'  
  , gateway: 'gateway.push.apple.com' 
  , port: 2195 
  , enhanced: true 
  , errorCallback: function(n, z) { console.log("oops?); } 
  , cacheLength: 1 
};

var connection = new apns.connection(options);

var note = new apns.notification();
note.badge = 1;
note.sound = "ping.aiff";
note.alert = "Something";

var token = 'dfsf';
note.device = new apns.device(token);
connection.sendNotification(note);

Notification not sent

Hi,

I just installed your module via npm, but when I'm trying to send notification to a device, I don't receive it ... here my code

var apns = require('apn');

var connection_options = {
    cert:'certificates/1234567890-dev-cert.pem',      /* Certificate file */
    certData:null,                              /* Optional: if supplied uses this instead of Certificate File */
    key:'certificates/1234567890-dev-key.pem',  /* Key file */
    keyData:null,                               /* Optional: if supplied uses this instead of Key file */
    passphrase:'beatblaster123',                            /* Optional: A passphrase for the Key file */
    ca: null,                          /* String or Buffer of CA data to use for the TLS connection */
    gateway:'gateway.sandbox.push.apple.com',   /* gateway address */
    port:2195,                                  /* gateway port */
    enhanced:true,                              /* enable enhanced format */
    errorCallback:undefined,                    /* Callback when error occurs */
    cacheLength:100                               /* Number of notifications to cache for error purposes */
};

var apnsConnection = new apns.Connection(connection_options);

function send_notification(parameters, response)
{
    util.log(parameters.DEVICE_TOKEN);

    var myDevice = new apns.Device(parameters.DEVICE_TOKEN);
    var note = new apns.Notification();

    note.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.
    note.badge = 1;
    note.sound = "ping.aiff";
    note.alert = "You have a new message";
    note.payload = {'messageFrom': 'Caroline'};
    note.device = myDevice;

    apnsConnection.sendNotification(note);
}

Thank you for your help !

Custom payload not coming through

Running bleeding-edge v1.1.0: the receiving end is missing the custom payload.

Sent from the server:

var note = new apns.notification();
note.badge = 3;
note.sound = "ping.aiff";
note.alert = "You have a new message";
note.payload = {'messageFrom': 'Caroline'};
note.device = myDevice;
apnsConnection.sendNotification(note);

Received on iOS

{"alert":"You have a new message","sound":"ping.aiff","badge":3}

(I double-checked my code in iOS...I hav a debug statement that spits out the notificationMessage object immediately after it is received so I have come to the conclusion that the sending component isn't sending everything

Syntax error

#159-160

it reads typeof errorCallback == 'function', it should be typeof options.errorCallback == 'function

same with #160

Fail to create a notification with badge

Badges are not set correctly in a notification.

in lib/notification.js, line 36:
notification.badget = this.badge;
should be:
notification.badge = this.badge;

Logging System

Implement a logging system with different levels to monitor connections when problems occur.

Option to place payload into notification.payload.aps

We are currently moving the handling of push notifications from urban airship to our own integration. Using Urban Airship before, our custom payload object appeared within the aps key and not on the root level of the notification. Right now, worked around this by adding the following code into the Notification.prototype.toJSON function...

if(this.payload.m) {
  this.payload.aps.m = _.clone(this.payload.m);
  delete(this.payload.m);
}

While this.payload.m actually holds our custom key/values.

It would be great if there would be a native way to place key/values into notification.payload.aps instead of notification.payload ...

Feedback callback token

Hey there. I was wondering if there is any particular reason that I may not see or understand regarding the feedback callback returning the device object with a binary token. It seems that the only part of this device object is the token, so I was curious if maybe it made more sense to just return the string version of the token.

I was able to figure out how to get the string, as I'm guessing others were able to as well, but just for future reference if anyone stumbles on this issue looking for an answer:

var options = {
    cert: 'cert.pem',                   /* Certificate file */
    certData: null,                     /* Certificate file contents */
    key:  'key.pem',                    /* Key file */
    keyData: null,                      /* Key file contents */
    passphrase: null,                   /* Optional: A passphrase for the Key file */
    address: 'feedback.push.apple.com', /* feedback address */
    port: 2196,                         /* feedback port */
    feedback: function(time, device) {
      var token = device.token.toString('hex');
      console.log(token);
    },                    /* enable feedback service, set to callback */
    interval: 3600                      /* interval in seconds to connect to feedback service */
};

var feedback = new apns.Feedback(options);

Newbie question on sending a notification

This is the device token
My token is: <d5c1e588 9d336101 fb74bdea ae64b61e 037cc958 f27d50dd xxxxxx xxxxxxx>

So,

var token = new Buffer("<d5c1e588 9d336101 fb74bdea ae64b61e 037cc958 f27d50dd xxxxxx xxxxxxx>", "utf-8")

var myDevice = new apns.Device(token, ascii=false);
var note = new apns.Notification();

note.badge = 3;
note.alert = "You have a new message";
note.device = token;


apnsConnection.sendNotification(note);

I'm getting nothing back!! I have no idea what's going on...

Sorry for a newbie question :)

Thanks,

Sending unified emoji via apn

Hello again Argon,

Thanks for your work on the reliability issue with bobrik. Another issue came up... I'm not sure if it's an issue on the node-apn side or on the Apple gateway side. Basically, alerts with the emoji unified standard unicode are dropped. Everything on the node side seems to work normally, but the message never arrives on the phone. If I use the old emoji softbank unicode char, for example '\ue415' for a smiley face, it works fine. If I use the new unified unicode standard, which the iPhone emoji keyboard outputs, for example '\uD83D\uDE04', it fails. Given your knowledge of apn on the node side and apple side, perhaps you might have some insight. It's possible that Apple's APN service hasn't caught up with the unified standard or doesn't accept the extended character set. Thank you for any help!

Dave

[Error: write EPIPE] still found after sent about 300 notifications, total about 480.

apn Socket writeable +0ms
apn Sending notification from buffer +0ms
apn Socket error occurred +0ms { [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', syscall: 'write' }
apn Raising error: +1ms { [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', syscall: 'write' } null
server { [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', syscall: 'write' } +116ms err_cb
apn Destroying connection +1ms
apn Sending notification +0ms
apn Buffering notification +0ms
apn Restarting connection +0ms
apn Notification queue has 125 items, resending the first +0ms
apn Initialising connection +0ms
apn Connection established +1s
apn Sending notification +0ms
apn Socket drained +0ms
apn Socket writeable +0ms
apn Sending notification from buffer +0ms
apn Sending notification +1ms

handling socket errors, avoiding instance die

Hi!

First of all, thanks for your (good) work! Really helpful, save hours of work for me :D
For some reason my network (I'm not sure what, but I guess: Internet provider, router...) or maybe the server's OS... something breaks my socket opened connections if no activity is detected. When it happens node-apn makes node instance die.
However, the solution is quite simple: just catch the error:

self.socket.on('error', function(data) { self.socket = undefined; });

Obviously, that piece of code can be improved ;)

Thanks again!

Error with setting payload

Receive this error when I try to set the payload.

/usr/local/lib/node_modules/apn/lib/apn.js:190
this.payload.aps.badge = this.badge;

My code currently looks like:

var data = JSON.parse(job.data);

var device = new apns.device(data.deviceToken);
var note = new apns.notification();

note.badge = 1;
note.sound = 'default';
note.alert = data.alert;
note.payload = data.payload;
note.device = device;

apnsConnection.sendNotification(note);```

try to send notification with no success

Hi all
I tried to send push notification, I have already create the cert.pem, key.pem file follow the instruction.

This is my server

var apns = require('apn');
var Apn = require('./apn_instance');

(function(){
console.log('Creating the apple push notification server...');

var apn = new Apn({cert : "cert.pem", key : "key.pem"});
var apnsConnection = apn.apnConnection();

//Get array of token from the application db 
var tokens = ["XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"];
for(var i = 0; i < tokens.length; i++){
    console.log(tokens[i]);
    var device = apn.getDevice(tokens[i]);

    var note = new apns.Notification();
    note.badge = 3;
    note.sound = "ping.aiff";
    note.alert = "You have a new message";
    note.payload = {'messageFrom': 'Bla bla bla bla'};
    note.device = device;
    console.log("before sending");
    apnsConnection.sendNotification(note);      
    console.log("after sending");
}   

})();

this is my instanse code:

var apns = require('apn');

function Apn(_obj){
this.cert = _obj.cert;
this.key = _obj.key;
console.log(this.cert);
var options = {

    cert: this.cert,                  // 'cert.pem',                 /* Certificate file */
    certData: null,                   /* Optional: if supplied uses this instead of Certificate File */
    key:  this.key,                   //'key.pem',                  /* Key file */
    keyData: null,                    /* Optional: if supplied uses this instead of Key file */
    passphrase: 'gamera',                 /* Optional: A passphrase for the Key file */
    gateway: 'gateway.push.apple.com',/* gateway address */
    port: 2195,                       /* gateway port */
    enhanced: true,                   /* enable enhanced format */
    errorCallback: function(e, n){
        console.log(e);
    },         /* Callback when error occurs */
    cacheLength: 5                    /* Number of notifications to cache for error purposes */
};

}

can some one please help me?
Apn.prototype.apnConnection = function(){
var apnsConnection = new apns.Connection(this.options);
return apnsConnection;
}

Apn.prototype.getDevice = function(token){
var device = new apns.Device(token /, ascii=true
/);
return device;
}

module.exports = Apn;

Error with many push messages

When I try to send 500 different push messages to different clients I get the next error:

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: Cannot call method 'removeAllListeners' of undefined
    at CleartextStream.<anonymous> (/usr/local/lib/node_modules/apn/lib/apn.js:52:55)
    at CleartextStream.emit (events.js:64:17)
    at Socket.onerror (tls.js:888:17)
    at Socket.emit (events.js:64:17)
    at Array.<anonymous> (net.js:828:27)
    at EventEmitter._tickCallback (node.js:126:26)

Error: write EPIPE (crash version 1.2.4)

TLS: reading from clearOut
TLS: reading from clearOut
TLS: cleartext emit "data" with 6 bytes
apn Notification 0 caused an error: 8 +69ms
apn Raising error: +0ms 8 { }
errorCallback code:8 { }
apn Buffering 50 notifications +1ms
apn Destroying connection +0ms
TLS: reading from clearOut
TLS: encrypted._push
NET: destroy
NET: close
apn Restarting connection +1ms
apn Notification queue has 689 items, resending the first +0ms
apn Initialising connection +0ms

events.js:48
throw arguments[1]; // Unhandled 'error' event
^
Error: write EPIPE
at errnoException (net.js:670:11)
at Object.afterWrite [as oncomplete] (net.js:503:19)

Thanks

Connection errors - Throw error when the connection couldn't be established?

Hi!,
Is there any way to handle connection errors? For example when the socket is closed or the certificate has expired and Apple closes the connection. We are dealing with this problem and we don't want our server to continue running if an connection error occurs. The apn connection is critial to our server.

Thank you very much!,

Matías

Push notification doesnt work for some devices

Hey there,
First of all, thank you so much for the library, it saved me a lot of time :)

I have two devices here,
iPhone - '3380654fef86453b712f47edf10357190297f05d25842683c43b7b3a3122ff44'
iPad '78c6e3701b57352d0c2ba07037581c952ad5e63fa6e5b4b200e8b0950e287d7a'

I managed to receive push notification on the iPad but couldnt receive any on the iPhone.
It works on two devices with some other simple push php that I found online.

"data" printed right before "self.socket.write(data);" under "writeNotificationToSocket" seems to be correct and shows no error.
Any other way I can try out to find the reason?

Thank you!

mocha unit tests show error: global memory leak on newing a connection

Not sure if this is a valid error or not but was trying to set up some unit testing with mocha and I get the error "Error: global leak detected: hasCert" when I try to create an apn connection

e.g.
apnsConnection = new apns.connection config.apnOptions

creates error

 Error: global leak detected: hasCert
  at Runner.checkGlobals (/usr/lib/node_modules/mocha/lib/runner.js:96:21)
  at Runner.<anonymous> (/usr/lib/node_modules/mocha/lib/runner.js:41:44)
  at Runner.emit (events.js:64:17)
  at /usr/lib/node_modules/mocha/lib/runner.js:159:12
  at Hook.run (/usr/lib/node_modules/mocha/lib/runnable.js:114:5)
  at next (/usr/lib/node_modules/mocha/lib/runner.js:157:10)
  at Array.<anonymous> (/usr/lib/node_modules/mocha/lib/runner.js:165:5)
  at EventEmitter._tickCallback (node.js:126:26)

Feedback not work using 1.2.3 or 1.2.0

at the time of tis.connection, that passed in host name is not valid, but after fixing it, I still not able to get any feedback, seems the
receive code not invoked at all.

errorCallback() returns wrong notification

When I send messages to 3 devices (2 valid, 1 invalid) at once, the errorCallback() gives me the the notification.device.token for one of the valid devices, not the one that actually caused the error. The errorCallback() returns always the last device from the batch, not the one that was actually falsely. Can anyone confirm this?

sometimes feedback.js throw error on this.readBuffer.length

sometimes this error occurred, not every time.

apnfb Connection established +1s
apnfb Received packet of length: 38 +6s

********/nt_apns_1.1/node_modules/apn/lib/feedback.js:173
var newBuffer = new Buffer(this.readBuffer.length + data.length);
^
TypeError: Cannot read property 'length' of null
at Feedback.receive (/share/app/nt_apns_1.1/node_modules/apn/lib/feedback.js:173:44)
at CleartextStream.EventEmitter.emit (events.js:88:17)
at CleartextStream.CryptoStream._push (tls.js:481:12)
at SecurePair.cycle (tls.js:839:20)
at EncryptedStream.CryptoStream.write (tls.js:220:13)
at Socket.ondata (stream.js:38:26)
at Socket.EventEmitter.emit (events.js:88:17)
at TCP.onread (net.js:403:14)

Default configuration unclear

Add logging to indicate whether running in a production or a development environment.
Update docs to indicate that the shown configuration is the default and only differences need to be given.

Getting EPIPE errors in node 0.6.10 and apn 1.1.6

It seems like whenever we do a sendNotification and there's an Error 8 "invalidToken" Apple must be disconnecting the socket and we get an EPIPE error thrown. The error looks like (probably not very helpful as it's coming from the net object):
Error: 8 : invalidToken

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: write EPIPE
at errnoException (net.js:642:11)
at Object.afterWrite as oncomplete

I tried to track things as far as the startSocket() from the self.socket.once('close'...) but I can't seem to track down what's causing the issue, it should be reconnecting I think. Any help would be appreciated.

successCallback ?

i tried to investigate the events the socket triggers:

successfully sent

 writeToSocket
 socket.write <Buffer>
 onDrain called with writeBuffer.length 0
 drained

error

 writeToSocket
 socket.write <Buffer>
 onDrain called with writeBuffer.length 0
 drained
 socket on data <Buffer 08 08 00 00 00 00>
 errorCallback
 socket close

both success & error, have the first four events common. the only difference with error is that data is returned on the same socket, and then closed.

is it possible to set a successcallback (that doesnt rely on timers for an error to come back ) ?

~B

help with 255 errors

I'm getting 255 errors with some regularity.

These errors, according to Apple's documentation, the reason is: None (unknown).

I'm wondering if anyone else sees these and knows what tends to cause them.

Also, the notification that caused the error is undefined so it's quite hard to track what the cause might be. Is this because Apple doesn't actually tell your or is the reference just getting lost?

Large volume of notifications

Hello,

I use your plugin to send a large amount of notifications (~ 1 000 000) as quickly as possible (2 minutes will be a great time). I build an architecture to do that :

  • My notications are stocked in redis
  • I have 10 workers that take several notifications from redis and send them with your module "node-apn". Each worker have it's own connection.

Unfortunately i am having problems with the sending, i know (because i have some spies in the 1 000 000) that not everybody received the notifications.

I experienced that if i send notifications slowly, the efficiency is better..

To optimize my sending, i restart the connection every 200 notifications (i use my fork of your project to do that), it's better but not clever.

Do you have some idea to help me apart from the sending time increase ?

Thanks,
Greg

Syntax error in feedback.js

There is a little syntax error

in lib/feedback.js, line 214:
if(!this.deferredConnection.promise.isResolved() {

should be:
if(!this.deferredConnection.promise.isResolved()) {

Is their a reason expiry is not exposed?

We are looking into using this for a push notification system, however after going over the code and such it seems that expiry = 0 which is I guess apples default and wont store the push notification to retry.

We would like to be able to set expiry value, so lets say its a special holiday to send that push to the user until 24 hours aka the holiday would be up at that time and dont send it to users who didnt get it.

thoughts?

Render issue with Express on Heroku

Hi.

I'm try to deploy an app on heroku and I've got a behavior different from my local install.

in the Heroku logs: "Can't use mutable header APIs after sent."

here is my test action:
exports.test = function(req, res){
var apnsDevice = new apns.Device('7335c2dfb5a9922688a486612933fedc5e218fbc7ba6b3e16dfaf68b211ec648');
var note = new apns.Notification();
note.alert = 'this is a test';
note.device = apnsDevice;
apnsConnection.sendNotification(note);
res.render('index',{title:'test'});
};

just in case, the full heroku log:

2012-07-15T00:26:17+00:00 app[web.1]: Error: Unknown encoding
2012-07-15T00:26:17+00:00 app[web.1]: at Buffer.write (buffer.js:274:13)
2012-07-15T00:26:17+00:00 app[web.1]: at new Buffer (buffer.js:180:26)
2012-07-15T00:26:17+00:00 app[web.1]: at new Device (/app/node_modules/apn/lib/device.js:8:16)
2012-07-15T00:26:17+00:00 app[web.1]: at /app/routes/index.js:46:20
2012-07-15T00:26:17+00:00 app[web.1]: at callbacks (/app/node_modules/express/lib/router/index.js:165:11)
2012-07-15T00:26:17+00:00 app[web.1]: at param (/app/node_modules/express/lib/router/index.js:139:11)
2012-07-15T00:26:17+00:00 app[web.1]: at pass (/app/node_modules/express/lib/router/index.js:146:5)
2012-07-15T00:26:17+00:00 app[web.1]: at Router._dispatch (/app/node_modules/express/lib/router/index.js:173:4)
2012-07-15T00:26:17+00:00 app[web.1]: at Object.router as handle
2012-07-15T00:26:17+00:00 app[web.1]: at next (/app/node_modules/express/node_modules/connect/lib/proto.js:190:15)
2012-07-15T00:26:17+00:00 app[web.1]:
2012-07-15T00:26:17+00:00 app[web.1]: http.js:543
2012-07-15T00:26:17+00:00 heroku[router]: GET rsspush-rudebaguette.herokuapp.com/test dyno=web.1 queue=0 wait=0ms service=10ms status=500 bytes=3699
2012-07-15T00:26:17+00:00 app[web.1]: throw new Error("Can't use mutable header APIs after sent.");
2012-07-15T00:26:17+00:00 app[web.1]: ^
2012-07-15T00:26:17+00:00 app[web.1]: Error: Can't use mutable header APIs after sent.
2012-07-15T00:26:17+00:00 app[web.1]: at ServerResponse.getHeader (http.js:543:11)
2012-07-15T00:26:17+00:00 app[web.1]: at /app/node_modules/express/node_modules/connect/lib/middleware/logger.js:230:26
2012-07-15T00:26:17+00:00 app[web.1]: at ServerResponse. (/app/node_modules/express/node_modules/connect/lib/middleware/logger.js:150:20)
2012-07-15T00:26:17+00:00 app[web.1]: at /app/node_modules/express/node_modules/connect/lib/middleware/errorHandler.js:65:17
2012-07-15T00:26:17+00:00 app[web.1]: at [object Object]. (fs.js:107:5)
2012-07-15T00:26:17+00:00 app[web.1]: at [object Object].emit (events.js:61:17)
2012-07-15T00:26:17+00:00 app[web.1]: at afterRead (fs.js:878:12)
2012-07-15T00:26:17+00:00 app[web.1]: at wrapper (fs.js:245:17)
2012-07-15T00:26:18+00:00 heroku[web.1]: Process exited with status 1
2012-07-15T00:26:18+00:00 heroku[web.1]: State changed from up to crashed

I'm a beginner on Node.js
Am I doing something wrong?

Thanks!
Thibaut

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.