简体   繁体   English

推送通知服务器实现

[英]Push notifications server implementation

I'm trying to make work apns-php (http://code.google.com/p/apns-php/) on my server (Bluehost with dedicated IP and port 2195 open for tcp and udp outgoing). 我正在尝试在我的服务器上创建工作apns-php(http://code.google.com/p/apns-php/)(具有专用IP的Bluehost和用于tcp和udp传出的端口2195)。

I'm getting this error: 我收到这个错误:

Fatal error: Uncaught exception 'ApnsPHP_Exception' with message 'Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195': (0)' in /home2/xxxxx/public_html/xxxxx/pns/ApnsPHP/Abstract.php:352 Stack trace: #0 /home2/xxxxx/public_html/xxxxx/pns/ApnsPHP/Abstract.php(295): ApnsPHP_Abstract->_connect() #1 /home2/xxxxx/public_html/xxxxx/pns/sample_push.php(41): ApnsPHP_Abstract->connect() #2 {main} thrown in /home2/xxxxx/public_html/xxxxx/pns/ApnsPHP/Abstract.php on line 352 致命错误:未捕获异常'ApnsPHP_Exception',消息'无法连接到'ssl://gateway.sandbox.push.apple.com:2195':( 0)'/ home2 / xxxxx / public_html / xxxxx / pns / ApnsPHP /Abstract.php:352堆栈跟踪:#0 /home2/xxxxx/public_html/xxxxx/pns/ApnsPHP/Abstract.php(295):ApnsPHP_Abstract - > _ connect()#1 / home2 / xxxxx / public_html / xxxxx / pns / sample_push.php(41):第352行/home2/xxxxx/public_html/xxxxx/pns/ApnsPHP/Abstract.php中引发的ApnsPHP_Abstract-> connect()#2 {main}

I have contact Bluehost support and they told me this: 我有联系Bluehost的支持,他们告诉我这个:

Thanks for contacting us. 谢谢您联络我们。 If seems as though the server ssl://gateway.sandbox.push.apple.com:2195* is refusing to accept the connection made from your account. 如果服务器ssl://gateway.sandbox.push.apple.com:2195 *似乎拒绝接受您帐户的连接。 Is there a way you can whitelist your dedicated ip or accept incoming connections on their end? 有没有办法可以将您的专用IP列入白名单或接受传入的连接?

Someone can help me to solve this out? 有人可以帮我解决这个问题吗? Any ideas? 有任何想法吗? Thanks! 谢谢!

I have found a solution, I don't know if it's the best, but it works. 我找到了一个解决方案,我不知道它是否是最好的,但它确实有效。 On Abstract.php (this file is part of the apns-php source) I have commented the line 343. Now it looks like this: 在Abstract.php(这个文件是apns-php源代码的一部分)我评论了第343行。现在它看起来像这样:

$streamContext = stream_context_create(array('ssl' => array(
//'verify_peer' => isset($this->_sRootCertificationAuthorityFile),
'cafile' => $this->_sRootCertificationAuthorityFile,
'local_cert' => $this->_sProviderCertificateFile
)));

I really don't know what is the point of this line, but know the push notification is working properly. 我真的不知道这一行有什么意义,但知道推送通知正常工作。 My doubt is if it will work properly too on production server. 我怀疑它是否能在生产服务器上正常工作。 Someone knows? 有人知道吗?

In our case we did not do the last part of this tutorial; 在我们的例子中,我们没有完成本教程的最后一部分; http://code.google.com/p/apns-php/wiki/CertificateCreation (thinking it was optional) http://code.google.com/p/apns-php/wiki/CertificateCreation (认为​​它是可选的)

Which resulted in exactly the same errors as you had. 这导致了与您完全相同的错误。

After we did that, everything worked as expected. 在我们这样做之后,一切都按预期工作。

I had same issue and what I did wrong was providing same certificate for SSL client authentication and the root CA, below code worked for me 我有同样的问题,我做错了是为SSL客户端身份验证和根CA提供相同的证书,下面代码为我工作

$push = new ApnsPHP_Push(
        ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
        'ck.pem'
    );

$push->setRootCertificationAuthority('entrust_root_certification_authority.pem');

https://code.google.com/p/apns-php/wiki/CertificateCreation https://code.google.com/p/apns-php/wiki/CertificateCreation

你可能需要联系苹果..因为它听起来是苹果阻止你的应用程序访问他们的网关..你需要联系苹果,以便你可以获得你的IP地址或网络应用程序批准

This problem is exactly what i was seeing in local development. 这个问题正是我在本地开发中看到的。 I'm assuming you'd want to uncomment that line once it's on the server and the certs are all setup properly. 我假设您想要在服务器上取消注释该行,并且所有证书都已正确设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM