2012-11-30 14 views
5

私はAPNに接続しようとしています。それは単に接続しません。これは、通帳のパスですnode-apnを接続できません

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

apn Connection error occurred before TLS Handshake +0ms 

:私はのバリエーションを取得します。アプリではありません。私は通帳証明書を使用しています。

私のコードは次のとおりです。

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

答えて

1

私は証明書を混ぜているようです。私は早くそれらを交換しようとしましたが、明らかにそうしなかったと確信しています。


証明書:あなたのアプリの証明書。
キー:アップルのWWDR

0

は、プロキシの背後にありますか?手動.cert.keyファイルを読み、certDataとして、それらを設定し、keyData財産、respectivelly:それは次のような構造をしてみ

+1

いいえ、私はローカルマシンとHerokuの両方で試しました。 – Simon

+0

その後、ここにお手伝いするのは簡単ではありません;-( – hereandnow78

+0

心配しないでください。 – Simon

0

(少なくとも、それは私の場合であることが多い)の問題である可能性があります。ここにコアがあります:

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

残念ながら、私はそれを試みましたが、うまくいきません。 – Simon

関連する問題