问题:我无法访问 APNS 服务器。我收到 110 连接超时错误。
我的情况:
- 我已经联系了我的主人(hostmonster)。他们说我的 2195,2196 端口已经开放。
- 我的证书和密码没有问题,因为我已经在本地 Mac 上对其进行了测试。
我用一个很简单的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);