parse-server-push-adapter:APNS 找不到有效连接

Posted

技术标签:

【中文标题】parse-server-push-adapter:APNS 找不到有效连接【英文标题】:parse-server-push-adapter: APNS cannot find vaild connection 【发布时间】:2016-04-14 10:05:55 【问题描述】:

这是我的 Heroku 日志,我不知道是什么问题...:

2016-04-14T09:56:46.723445+00:00 heroku[router]: at=info method=POST path="/parse/classes/Events" host=chilln.herokuapp.com request_id=4b74dc5d-c6e9-41cc-b969-362cf164e623 fwd="80.12.42.35" dyno=web.1 connect=1ms service=544ms status=200 bytes=502
2016-04-14T09:56:52.765295+00:00 heroku[router]: at=info method=POST path="/parse/push" host=chilln.herokuapp.com request_id=632a572e-6b6b-4e45-8b55-fd3743a39f56 fwd="54.155.74.212" dyno=web.1 connect=1ms service=7ms status=200 bytes=482
2016-04-14T09:56:52.796599+00:00 heroku[router]: at=info method=POST path="/parse/classes/Events" host=chilln.herokuapp.com request_id=1d04587e-f44b-4e10-8af4-a96a9807295c fwd="80.12.42.35" dyno=web.1 connect=0ms service=75ms status=200 bytes=502
2016-04-14T09:56:52.736079+00:00 app[web.1]: test
2016-04-14T09:56:52.806494+00:00 app[web.1]: Message was sent successfully
2016-04-14T09:56:52.833462+00:00 app[web.1]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 151b6e146dccc1f9336eca4a3c47188c3fddcf2598d3a7730324ee688e225bf9
2016-04-14T09:56:52.834235+00:00 app[web.1]: ERR! parse-server-push-adapter APNS cannot find vaild connection for b4b91a9124e6f0e49b3dc7b5a5a07529035f4773ebb9a727f51d3c7a7e1fbb87
2016-04-14T09:56:52.834452+00:00 app[web.1]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 1d0f91f81633e75374272ef987e7c67affc8cd59d1d3a09b6a46acc0a07165fb
2016-04-14T09:56:52.834610+00:00 app[web.1]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 5516634cf80839bb193975171d7c89197d2dcc9534aab8586d74248c8474aaa3
2016-04-14T09:56:52.834768+00:00 app[web.1]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 8d2b77001ce5dd6cd9c07fa7184737679ca67e3c65018942b1b5f1406e75c1ea
2016-04-14T09:56:52.834921+00:00 app[web.1]: ERR! parse-server-push-adapter APNS cannot find vaild connection for bf028bb136eb408e4a852a549a14e13f185738e2c562718120b72c937589ba18
2016-04-14T09:56:52.836334+00:00 app[web.1]: /app/node_modules/parse-server/lib/ParseServer.js:333
2016-04-14T09:56:52.836344+00:00 app[web.1]:             throw err;
2016-04-14T09:56:52.836345+00:00 app[web.1]:             ^
2016-04-14T09:56:52.836346+00:00 app[web.1]: 
2016-04-14T09:56:52.836346+00:00 app[web.1]: Error: ENOENT: no such file or directory, open 'cert.pem'
2016-04-14T09:56:52.836347+00:00 app[web.1]:     at Error (native)
2016-04-14T09:56:52.848093+00:00 app[web.1]: 
2016-04-14T09:56:52.854877+00:00 app[web.1]: npm ERR! Linux 3.13.0-79-generic
2016-04-14T09:56:52.855184+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-04-14T09:56:52.855346+00:00 app[web.1]: npm ERR! node v5.10.0
2016-04-14T09:56:52.856135+00:00 app[web.1]: npm ERR! npm  v3.8.3
2016-04-14T09:56:52.856272+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-04-14T09:56:52.856397+00:00 app[web.1]: npm ERR! parse-server-example@1.1.0 start: `node index.js`
2016-04-14T09:56:52.856487+00:00 app[web.1]: npm ERR! Exit status 7
2016-04-14T09:56:52.856606+00:00 app[web.1]: npm ERR! 
2016-04-14T09:56:52.856726+00:00 app[web.1]: npm ERR! Failed at the parse-server-example@1.1.0 start script 'node index.js'.
2016-04-14T09:56:52.856875+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2016-04-14T09:56:52.856907+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the parse-server-example package,
2016-04-14T09:56:52.857013+00:00 app[web.1]: npm ERR! not with npm itself.
2016-04-14T09:56:52.857124+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2016-04-14T09:56:52.857232+00:00 app[web.1]: npm ERR!     node index.js
2016-04-14T09:56:52.857313+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2016-04-14T09:56:52.857438+00:00 app[web.1]: npm ERR!     npm bugs parse-server-example
2016-04-14T09:56:52.857545+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2016-04-14T09:56:52.857649+00:00 app[web.1]: npm ERR!     npm owner ls parse-server-example
2016-04-14T09:56:52.857750+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2016-04-14T09:56:52.861108+00:00 app[web.1]: 
2016-04-14T09:56:52.861248+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-04-14T09:56:52.861351+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-04-14T09:56:52.821789+00:00 heroku[router]: at=info method=POST path="/parse/functions/pushToAll" host=chilln.herokuapp.com request_id=89b9ee9e-384f-48c4-b1d3-8c36f0b6bb94 fwd="80.12.42.35" dyno=web.1 connect=1ms service=78ms status=200 bytes=484
2016-04-14T09:56:53.646012+00:00 heroku[web.1]: State changed from up to crashed
2016-04-14T09:56:53.634703+00:00 heroku[web.1]: Process exited with status 1

这里是我的index.js,我觉得问题出在这里。

我在这个文件夹 index.js 中有文件夹 parse-server。在 parse-server 文件夹中,我有另一个名为“certs”的文件夹,该文件夹中有 ParsePushDevelopmentCertificate.p12 文件

var api = new ParseServer(  
    databaseURI: process.env.DATABASE_URI || 'mongodb://localhost:27017/dev',  
    cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
    appId: 'xx',  
    masterKey: 'xx',
    fileKey: 'xx',  
    clientKey: 'xx',
    serverURL: 'http://myApp.herokuapp.com/parse',
    push: 
    ios: [
      
        pdx: __dirname + '/certs/ParsePushDevelopmentCertificate.p12', // Dev PFX or P12
        bundleId: 'myBundleId',
        production: false // Dev
      
    ]
  
);

【问题讨论】:

保留__dirname + '/,因为 ParseServer 无论如何都会这样做。 【参考方案1】:

显然您的问题是找不到您的 .pem 文件。

【讨论】:

【参考方案2】:

我在此post 中提供了关于找不到有效连接错误的更详细答案。

简而言之,您的安装表中有记录与您应用于 push 请求的过滤器相匹配,这些记录不再在 Apple 中为您的应用注册,这就是它们返回到这些类型的请求。如果您从安装表中删除与错误消息中返回的deviceToken 匹配的记录,则错误将停止。

【讨论】:

以上是关于parse-server-push-adapter:APNS 找不到有效连接的主要内容,如果未能解决你的问题,请参考以下文章