无法从 php 连接到 apns

问题描述 投票:0回答:0

我无法从我的生产机器连接到 apple apns,它是一个 vps 主机。

  1. 我问过托管技术援助,他们说他们不会阻止任何端口上的传出连接,日志也没有显示这个问题,他们不知道是什么原因造成的,所以没有帮助。
  2. 这适用于我的本地开发机器,iPhone 会收到通知。
  3. extension=php_openssl.dll
    在两台机器上的
    php.ini
    文件中启用。
  4. 在两台机器上
    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

由于连接失败,最后两个错误是给定的,但是前三个我无法解决。

任何帮助将不胜感激:)

php sockets ssl stream apple-push-notifications
© www.soinside.com 2019 - 2024. All rights reserved.