2012-11-30 12 views
5

Próbuję nawiązać połączenie z APN. Po prostu się nie połączy. I dostać odmiany:Nie można uzyskać węzła-apn do połączenia

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

i

apn Connection error occurred before TLS Handshake +0ms 

Jest to o przepustkę paszportowego. Nie aplikacja. Używam certyfikatów Passbook.

Mój kod to:

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

Odpowiedz

1

Wygląda na to, że pomieszałem moje certyfikaty. Jestem pewien, że próbowałam je wcześniej wymienić, ale oczywiście nie.


cert: Twoja aplikacja certyfik.
klawisz: Apple WWDR

0

jesteś za serwerem proxy? że może być problem (przynajmniej to często w moim przypadku)

+1

Nie. Próbowałem go zarówno na mojej lokalnej maszynie, jak i Heroku. – Simon

+0

następnie im przykro, nie jest łatwo ci pomóc ;-( – hereandnow78

+0

nie martw się, dziękuję, – Simon

0

Spróbuj następującą strukturę: Przeczytaj .cert i .key pliki ręcznie i ustawić je jako certData i keyData nieruchomości, respectivelly. Oto rdzeń:

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

Niestety próbowałem tego i to nie działa. – Simon

Powiązane problemy