代码之家  ›  专栏  ›  技术社区  ›  Viral Narshana

Apns php错误“无法连接到Apns:110连接超时。”

  •  5
  • Viral Narshana  · 技术社区  · 12 年前

    我已经完成了php和objective c的apns代码 Apns code

    和来自的安装证书 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设备发送通知?有人能为我指路吗?

    2 回复  |  直到 12 年前
        1
  •  4
  •   Viral Narshana    12 年前

    最后,我选择了vps而不是共享主机。 卢卡布罗的评论帮助我解决了问题。谢谢Lucabro。

        2
  •  0
  •   Viorel Baicu    6 年前

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

    Firebase云功能易于开发,而且几乎是免费的。

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

    我将在下周发布我的解决方案。