开发者

Unable to connect to apns from php

开发者 https://www.devze.com 2023-04-07 17:59 出处:网络
I am having trouble connecting to the apple apns from my production machine, its a vps hosting. I asked the hosting technical assistance and they said that they do not block outgoing connections on

I am having trouble connecting to the apple apns from my production machine, its a vps hosting.

  1. I asked the hosting technical assistance and they said that they do not block outgoing connections on any port and that the logs show nothing of this problem and they have no idea what might cause this, so no help there.
  2. This works on my local dev machine and the iPhone gets the notifications.
  3. extension=php_openssl.dll is enabled in the php.ini file on both machines.
  4. on both machines telnet gives a black screen and not a response like i saw on some threads here.

The code im using is:

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_cl开发者_运维问答ient('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);

And the error i get are:

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

The last 2 errors are a given as the connection fails but the first 3 i can't resolve.

Any help will be appritiated :)

0

精彩评论

暂无评论...
验证码 换一张
取 消