node.js – 无法连接node-apn

我正在尝试建立与APN的连接.它根本不会连接.我得到的变化:

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

apn Connection error occurred before TLS Handshake +0ms

这是Passbook通行证.不是应用程序.我正在使用Passbook证书.

我的代码是:

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

解决方法

看来我混淆了我的证书.我敢肯定我曾尝试过早更换它们,但显然没有.

证书:您的应用证书.关键:Apple的WWDR

相关文章

这篇文章主要介绍“基于nodejs的ssh2怎么实现自动化部署”的...
本文小编为大家详细介绍“nodejs怎么实现目录不存在自动创建...
这篇“如何把nodejs数据传到前端”文章的知识点大部分人都不...
本文小编为大家详细介绍“nodejs如何实现定时删除文件”,内...
这篇文章主要讲解了“nodejs安装模块卡住不动怎么解决”,文...
今天小编给大家分享一下如何检测nodejs有没有安装成功的相关...