function getConnection($certPemFile)
{
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $certPemFile);
$dsn = 'ssl://'.'gateway.push.apple.com:2195';
$socket = stream_socket_client($dsn, $errno, $errMsg, 3, (STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT), $ctx);
if(!$socket) {
printf("errno=%d errMsg=%s", $errno, $errMsg);
}
return $socket;
}
I connect to the APNS server with this code, but sometimes it returns $errno=0
and $errMsg=''
.
I have updated the .pem files.