4

问题:我无法访问 APNS 服务器。我收到 110 连接超时错误。

我的情况:

  1. 我已经联系了我的主人(hostmonster)。他们说我的 2195,2196 端口已经开放。
  2. 我的证书和密码没有问题,因为我已经在本地 Mac 上对其进行了测试。
  3. 我用一个很简单的PHP来测试。这是我的代码:

    $ctx = stream_context_create();
    stream_context_set_option($ctx, 'ssl', 'local_cert', 'apn.pem');
    stream_context_set_option($ctx, 'ssl', 'passphrase', 'aaa');
    $fp = stream_socket_client("ssl://gateway.sandbox.push.apple.com:2195", $err,     
          $errstr,60,STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT,$ctx);
    
    if ($fp)
        echo ('aa');
    else
        echo ($err.$errstr);
    
4

1 回答 1

10

I had the same exact problem, but with Bluehost. In my case, it turned out the Bluehost firewall was not properly open. The first line chat support from Bluehost said the ports 2195 & 2196 are open, and the problem was not with them. To demonstrate the problem was on their side, I asked them to run the following telnet command from the Bluehost server:

telnet gateway.push.apple.com 2195

Trying 17.149.36.246...
Trying 17.149.35.166...
Trying 17.149.35.170...
Trying 17.149.35.177...
... Connection timed out

The output should be:

telnet gateway.push.apple.com 2195

Trying 17.149.36.230...
Connected to gateway.push.apple.com.
Escape character is '^]'.

Then i submitted a support ticket to Bluehost with this information. They resolved the issue in 6 hours by properly opening the firewall.

于 2013-06-23T12:40:44.663 回答