Tuesday, 6 August 2013

Apple Push Notification Service connection, through proxy, timed out with stream_socket_client

Apple Push Notification Service connection, through proxy, timed out with
stream_socket_client

I'm trying to connect APNS, but i need to pass through a proxy, here the
connection test code:
if (!extension_loaded('openssl')) {
exit("need openssl");
}
$http = array();
$http['http']['proxy'] = 'tcp://proxy.net:8080';
$http['http']['request_fulluri'] = true;
$ssl = array();
$ssl['ssl']['local_cert'] = 'ck.pem';
$ssl['ssl']['passphrase'] = 'passphrase';
$opts = array_merge($http,$ssl);
$context = stream_context_create($opts);
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195',
$err, $errstr, 60, STREAM_CLIENT_CONNECT, $context);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
The problem is that I have always a timeout error, like if i make a direct
connection to apple gateway, like if options in stream_context_creat were
ognored.
OpenSSL and Socket support are enabled, and port 2195 is open.
Any ideas?

No comments:

Post a Comment