开发者

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).

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

I have contact Bluehost support and they told me this:

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开发者_StackOverflow社区? 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:

$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?


you may need to contact apple .. as by what it sounds like is that apple blocked ur application from accessing their gateway .. you would need to contact apple so that you can get your ip address or web app approved


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.


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)

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

$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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜