stream_socket_client在我的服务器上失败,无法进一步了解该错误 [英] stream_socket_client failing on my server with no way to know more about the error

查看:426
本文介绍了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.

我有这样的代码可以完美地在网站上运行(dev/beta/staging),而现在我正尝试进入生产环境,却没有.

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- Notifications/commit/0ae8a3ad3327a957c332090ea1bfcb146a40c5f3

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

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