I have an iOS app, I used apple push notification to send the notification when I write new post in my site, so there is php script has the ssl certificates , when I send the push notification it's usually deliver but in the error log I got this error:
[27-Mar-2013 15:30:44] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /home3/basiphon/public_html/Push.php on line 56
The push notification (usually) deliver successfully but I got this error in the error log, and there are sometimes the push notifcation not deliver and I got also this error to another error like this :
[27-Mar-2013 05:45:04] PHP Warning: stream_socket_client() [function.stream-socket-client]: SSL: connection timeout in /home3/basiphon/public_html/Push.php on line 56 [27-Mar-2013 05:45:04] PHP Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /home3/basiphon/public_html/Push.php on line 56 [27-Mar-2013 05:45:04] PHP Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /home3/basiphon/public_html/Push.php on line 56
Please see the code of my push.php script :
`// Open a connection to the APNS server
$fp = stream_socket_client(
$url, $err,
$errstr, 2, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
{
echo 'Message successfully delivered111' . PHP_EOL;
$query_update="update wp_apns_messages set status='delivered',delivery=NOW() where pid='$pid'";
$res_update=mysql_query($query_update) or die(mysql_error());
}
// Close the connection to the server
fclose($fp);`