php - ApnsPHP 无法连接到 Apple 网关

标签 php apple-push-notifications

今天突然出现了一个非常奇怪的错误,说它无法连接到适当的网关...有什么修复建议吗?

这是记录器输出:

Wed, 08 Jun 2011 15:05:44 +0200 ApnsPHP[21724]: INFO: Trying ssl://gateway.sandbox.push.apple.com:2195...
Wed, 08 Jun 2011 15:05:45 +0200 ApnsPHP[21724]: ERROR: Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195':  (0)
Wed, 08 Jun 2011 15:05:45 +0200 ApnsPHP[21724]: INFO: Retry to connect (1/3)...
Wed, 08 Jun 2011 15:05:46 +0200 ApnsPHP[21724]: INFO: Trying ssl://gateway.sandbox.push.apple.com:2195...
Wed, 08 Jun 2011 15:05:47 +0200 ApnsPHP[21724]: ERROR: Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195':  (0)
Wed, 08 Jun 2011 15:05:47 +0200 ApnsPHP[21724]: INFO: Retry to connect (2/3)...
Wed, 08 Jun 2011 15:05:48 +0200 ApnsPHP[21724]: INFO: Trying ssl://gateway.sandbox.push.apple.com:2195...
Wed, 08 Jun 2011 15:05:48 +0200 ApnsPHP[21724]: ERROR: Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195':  (0)
Wed, 08 Jun 2011 15:05:48 +0200 ApnsPHP[21724]: INFO: Retry to connect (3/3)...
Wed, 08 Jun 2011 15:05:49 +0200 ApnsPHP[21724]: INFO: Trying ssl://gateway.sandbox.push.apple.com:2195...

Fatal error: Uncaught exception 'ApnsPHP_Exception' with message 'Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195':  (0)' in /home/xxxx/xxxxx/ApnsPHP/Abstract.php:354

最佳答案

这个解决方案对我有用。原答案在 Push notifications server implementation -

我找到了一个解决方案,我不知道它是否是最好的,但它有效。在 Abstract.php(该文件是 apns-php 源代码的一部分)上,我注释了第 343 行。现在它看起来像这样:

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

我真的不知道这一行的意义是什么,但知道推送通知工作正常。

关于php - ApnsPHP 无法连接到 Apple 网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6279185/

相关文章:

ios - 续订 MDM APNS 证书但忘记使用哪个 Apple ID

ios - Apple 推送通知服务在提交后不起作用,但在沙箱中一切正常

javascript - json 字符串显示在控制台中,但 php 变量 print null

php - 使用变量结果创建新表失败

php - php (phpcassa) 中的最低可能 timeuuid

flutter - 使用 flutter firebase_messaging 插件发送通知声音

php - MySQL 插入 mbox 格式

php - 如何在Android中使用PHP从数据库MySQL获取表情符号

ios - didReceiveRemoteNotification 中的异步下载

swift - 我们是使用静态通知还是动态通知从服务器获取用户名和头像?