stream_socket_client 在我的服务器上失败,无法了解有关错误的更多信息 [英] stream_socket_client failing on my server with no way to know more about the error

查看:27
本文介绍了stream_socket_client 在我的服务器上失败,无法了解有关错误的更多信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这段代码:(https://github.com/stuffmc/Safari-Push-Notifications/blob/master/index.php#L195)

stream_socket_client('ssl://gateway.push.apple.com:2195', $error, $errorString, 
                      60, STREAM_CLIENT_CONNECT, $streamContext);

返回 false,但没有错误.这意味着当我发送到/v1/push 时,每个设备/令牌都会失败:( PHP 文档说:

returns false, but with no errors. It means that when I'm sending to /v1/push it fails for every device/token :( The PHP documentation says:

如果 errno 中返回的值为 0 并且函数返回 FALSE,则表明错误发生在 connect() 调用之前.这很可能是由于初始化套接字时出现问题.

If the value returned in errno is 0 and the function returned FALSE, it is an indication that the error occurred before the connect() call. This is most likely due to a problem initializing the socket.

我让这段代码完美地用于网站(开发/测试版/暂存),现在我正在尝试转向生产,但它没有.

I have this code running perfectly for a website (dev/beta/staging) and now that I'm trying to move to production, it doesn't.

我应该注意到那个调用

$ openssl s_client -connect gateway.push.apple.com:2195 -cert MyC.pem -key myK.pem

完美运行.我有一个提示,我可以在其中输入字符,当输入 Enter 时,它会退出 - 与我的开发测试相同.

perfectly works. I have a prompt where I can type characters and when typing enter, it exits — same as with my dev test.

我也没有发送到 /v1/log(如 https 所述)://devforums.apple.com/thread/203825),所以我对问题出在哪里一无所知:(

I also have nothing sent to /v1/log (as mentionned at https://devforums.apple.com/thread/203825) and so I'm clueless as to where the problem would be :(

推荐答案

我通过这种方式生成 .pem 解决了我的问题:

I fixed my problem by generating the .pem this way:

openssl pkcs12 -in key-chain-export.p12 -out apple_push_cert_production.pem -nodes -clcerts

我仍然很想知道我怎么会得到一个提示"(来自 PHP 或 openssl),它是证书.

I still would love to know how I could have had a "hint" (from PHP or openssl) that it's the certificate.

AND:虽然它在服务器端解决了问题,但我在客户端遇到了问题.哦,好吧……

AND: Although it fixed the problem on the server side, I then got problems on the client side. Oh well.....

我还应该提到我修复了服务器上的代码,以便 /v1/log 从 Apple 获取一些东西.

I should also mention I fixed the code on the server so that /v1/log gets something from Apple.

参见 https://github.com/surrealroad/Safari-Push-通知/提交/0ae8a3ad3327a957c332090ea1bfcb146a40c5f3

这篇关于stream_socket_client 在我的服务器上失败,无法了解有关错误的更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆