I have a question about Apples Push Service. What do following warnings exactly mean?
Warning: stream_socket_client(): Failed to enable crypto in /opt/../xyz.php on line 150
Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /opt/../xyz.php on line 150
I am using about 5 different php files for sending push (AddFriendPush
, ChatMessagePush
...) to the iOS Devices and they are working fine. But sometime I get these warnings and I don't know what they mean but push doesn't work when I get these warnings..
I know that they can appear if your pem file is wrong or the port 2195 is blocked. But push works sometimes and sometimes it doesn't. So the pem file has to be right and the port can't be blocked.
I know it is not good to have 5 different scripts for push, I will change it soon.
Do you have any idea what is going on?
My php scripts look like this:
function sendPush($deviceToken, $msg)
{
$deviceToken = $deviceToken;
$passphrase = 'passhrase';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'Production.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$fp = stream_socket_client(
'ssl://gateway.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp) {
unset($con);
exit();
}
//do the other stuff
//Close the connection to the server
fclose($fp);
}