【问题标题】:Apns php error "Failed to connect to APNS: 110 Connection timed out."Apns php 错误“无法连接到 APNS:110 连接超时。”
【发布时间】:2013-10-02 06:13:17
【问题描述】:

我已经从 Apns code 为 php 和目标 c 完成了 apns 代码

并从this link设置证书

用于向 ios 设备发送通知的沙盒和生产 apns 在我的服务器上运行良好。我将代码和相同的证书移动到客户端服务器,然后发送通知不起作用。

我调试了所有php代码,发现停在这行代码

private function _connectSSLSocket($development) {
    $ctx = stream_context_create();
    stream_context_set_option($ctx, 'ssl', 'local_cert', $this->apnsData[$development]['certificate']);
    $this->sslStreams[$development] = stream_socket_client($this->apnsData[$development]['ssl'], $error, $errorString, 100, (STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT), $ctx);
    if(!$this->sslStreams[$development]){
        $this->_triggerError("Failed to connect to APNS: {$error} {$errorString}.");
        unset($this->sslStreams[$development]);
        return false;
    }
    return $this->sslStreams[$development];
}

apns.log 文件显示错误“无法连接到 APNS:110 连接超时。”

没有弄错。为什么我收到此错误而不向 ios 设备发送通知?有人可以指导我吗?

【问题讨论】:

  • 您客户端的服务器可能位于阻止端口 2195 的防火墙后面。
  • stackoverflow.com/questions/18085086/… 代理服务器导致的同样问题未解决,我们发现的唯一方法是允许直接连接到 apns
  • 啊,这样的问题你在共享主机中也会出现
  • 感谢大家的评论。是的,我有共享主机。有什么解决办法吗?
  • 尝试寻找 VPS 或外部服务来推送通知,例如 push.iopushwoosh.comopenpush.im

标签: iphone ios ipad apple-push-notifications apns-php


【解决方案1】:

最后我选择了 vps 而不是共享主机。 Lucabro 的 cmets 帮我解决了。谢谢 Lucabro。

【讨论】:

  • 你确定 iphone apns php 不能用于共享主机吗
  • @ReNiShAR 是的,我确定。
  • 我在共享主机上的脚本也遇到了这个问题。我们将问题告诉了主机,他们为我们在防火墙中启用了端口 2195 - 所以这可能值得一试。
【解决方案2】:

一个好的解决方案是使用像 firebase 这样的云功能来运行实际的 apns 连接,并在共享主机中为您的其他后端公开一个 API。 这是我在这个问题中运行时使用的。

Firebase 云功能易于开发且几乎免费。

https://firebase.google.com/docs/functions

我有时会在下周发布我的解决方案。

【讨论】:

    猜你喜欢
    • 2015-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-05
    • 1970-01-01
    • 2013-11-08
    相关资源
    最近更新 更多