2012-11-30 11 views
5

Sto tentando di stabilire una connessione con gli APN. Semplicemente non si connetterà. Ottengo variazioni:Impossibile ottenere node-apn per la connessione

apn Socket error occurred +609ms { [Error: socket hang up] code: 'ECONNRESET' } 

e

apn Connection error occurred before TLS Handshake +0ms 

Questo è per un passaggio libretto. Non è un'app. Sto usando certificati Passbook.

Il mio codice è:

var apns = require('apn'); 

var root = process.cwd(); 

var fs = require('fs'); 

var options = { 
    cert: root + '/certs/new/cert.pem',     /* Certificate file path */ 
    certData: null,     /* String or Buffer containing certificate data, if supplied uses this instead of cert file path */ 
    key: root + '/certs/new/key.pem',     /* Key file path */ 
    keyData: null,     /* String or Buffer containing key data, as certData */ 
    passphrase: 'secret',     /* 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 function(err,notification) */ 
    cacheLength: 100     /* Number of notifications to cache for error purposes */ 
}; 

var apnsConnection = new apns.Connection(options); 

var myDevice = new apns.Device('token'); 

var note = new apns.Notification(); 

note.payload = {}; 
note.device = myDevice; 

apnsConnection.sendNotification(note); 

risposta

1

Sembra che ho confuso i miei certificati. Sono sicuro di aver provato a scambiarli prima, ma ovviamente no.


cert: la tua app cert.
chiave: WWDR di Apple

0

si è dietro un proxy? che potrebbe essere il problema (almeno è spesso nel mio caso)

+1

No. L'ho provato sia sul mio computer locale che su Heroku. – Simon

+0

quindi mi dispiace, non è facile aiutarti qui ;-( – hereandnow78

+0

non ti preoccupare, grazie – Simon

0

Provare la seguente struttura: Leggere i file .cert e .key manualmente e impostarle come certData e keyData proprietà, respectivelly. Ecco il nucleo:

var key = root + '/certs/new/key.pem' 
var cert = root + '/certs/new/cert.pem'; 

var certData = fs.readFileSync(cert, encoding='ascii'); 
var keyData = fs.readFileSync(key, encoding='ascii'); 

var apnsConnection = new apns.Connection({ 
    certData: certData, 
    keyData: keyData, 
    gateway: 'gateway.sandbox.push.apple.com', 
    port: 2195, 
    ... /* other configs of course */ 
}); 
+0

Purtroppo l'ho provato e non funziona. Grazie. – Simon

Problemi correlati