I tested push notification on my local machine, it is working perfectly. I then uploaded my files to the real server with the same certificate (".pem" file), and I ensure that the ports 2195 and 2196 are open.
I tested:
telnet gateway.sandbox.push.apple.com 2195
It is working...
root@server ~ # telnet gateway.sandbox.push.apple.com 2195
Trying 17.149.34.54...
Connected to gateway.sandbox.push.apple.com.
Escape character is '^]'.
But when I test from my php script, it returns:
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection timed out)
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://feedback.sandbox.push.apple.com:2196
Any suggestions?
This is the php code:
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert',
"path/to/certificate");
$fp = stream_socket_client("ssl://gateway.push.apple.com:2195",
$error, $errorString, 100,
(STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT), $ctx);