推送通知服务器实现
我正在尝试在我的服务器上运行 apns-php (http://code.google.com/p/apns-php/)(Bluehost 具有专用 IP 和端口 2195,为 tcp 和 udp 传出打开).
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).
我收到此错误:
致命错误:未捕获的异常带有消息的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):ApnsPHP_Abstract->connect() #2 {main}扔进去/home2/xxxxx/public_html/xxxxx/pns/ApnsPHP/Abstract.php在线 352
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
我联系了 Bluehost 支持,他们告诉我:
I have contact Bluehost support and they told me this:
感谢您与我们联系.如果看起来像虽然服务器ssl://gateway.sandbox.push.apple.com:2195*拒绝接受连接由您的帐户制作.有没有办法您可以将您的专用 IP 列入白名单或接受他们的传入连接结束?
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. Is there a way you can whitelist your dedicated ip or accept incoming connections on their end?
有人可以帮我解决这个问题吗?有任何想法吗?谢谢!
Someone can help me to solve this out? Any ideas? Thanks!
推荐答案
我找到了一个解决方案,我不知道它是否是最好的,但它有效.在 Abstract.php(该文件是 apns-php 源代码的一部分)上,我注释了第 343 行.现在它看起来像这样:
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:
$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?
相关文章