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 any port and that the logs show nothing of this problem and they have no idea what might cause this, so no help there.
- This works on my local dev machine and the iPhone gets the notifications.
extension=php_openssl.dll
is enabled in thephp.ini
file on both machines.- 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 :)
精彩评论