我无法从我的生产机器连接到 apple apns,它是一个 vps 主机。
extension=php_openssl.dll
在两台机器上的 php.ini
文件中启用。telnet
给出黑屏而不是像我在这里的一些线程上看到的那样的响应。我使用的代码是:
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 10, STREAM_CLIENT_CONNECT, $streamContext);
$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', $deviceToken) . chr(0) . chr(strlen($payload)) . $payload;
fwrite($apns, $apnsMessage);
fclose($apns);
我得到的错误是:
Warning: stream_socket_client(): SSL: crypto enabling timeout in test.php on line 116
Warning: stream_socket_client(): Failed to enable crypto in test.php on line 116
Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in test.php on line 116
Warning: fwrite() expects parameter 1 to be resource, boolean given in test.php on line 118
Warning: fclose() expects parameter 1 to be resource, boolean given in test.php on line 119
由于连接失败,最后两个错误是给定的,但是前三个我无法解决。
任何帮助将不胜感激:)