Notification iPhone SDK Push randomly

I have a PHP file with the following content that works fine on developing ceritficates, but when I switch to the production certificate for PHP errors and give the message below, but it does it in about 50% of cases. Another 50% it works. Does anyone know why this might happen?

<?php
// masked for security reason 
$deviceToken = 'xxxxxx'; // jq

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', dirname(__FILE__)."/prod.pem");

$number = 5;

$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
  print "Failed to connect $err $errstr\n";
}
else {
  print "Connection OK\n";
  $msg = $_GET['msg'];
    $payload['aps'] = array('alert' => $msg, 'badge' => 1, 'sound' => 'default');
    $payload = json_encode($payload);

  $msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
  print "sending message :" . $payload . "\n";
  fwrite($fp, $msg);
  fclose($fp);
}
?>

PHP error:

Warning: stream_socket_client () [function.stream-socket-client]: it is not possible to install the local certificate chain file `/var/www/vhosts/thissite.com/httpdocs/prod.pem '; Make sure your cafile / capath settings contain information about your certificate and its issuer in /var/www/vhosts/thissite.com/httpdocs/pushMessageLive.php on line 19

: stream_socket_client() [function.stream-socket-client]: SSL /var/www/vhosts/thissite.com/httpdocs/pushMessageLive.php 19

: stream_socket_client() [function.stream-socket-client]: /var/www/vhosts/thissite.com/httpdocs/pushMessageLive.php 19

: stream_socket_client() [function.stream-socket-client]: ssl://gateway.sandbox.push.apple.com: 2195 ( ) /var/www/vhosts/thissite.com/httpdocs/pushMessageLive.php 19 0

+3
5

. Apple Push Notification Server. python pyapns (http://github.com/samuraisam/pyapns), :

http://www.how2s.org/index.php/How_to_get_started_with_Apple_Push_Notifications_for_iPhone_or_iPhone_Touch

, Debian , python-twisted, libcurl4-openssl-dev ..

+3

. Apple docs , , . DOS. , .

+1

, , , - push. , .

PHP, , , push-. , , stream_socket_client() fclose() ? SSL- PHP, , , ...

, Ruby , , ruby-apns-daemon, Apple. PHP ( - JSON, ruby-apns-daemon, ).

0

, . SSL- PHP ssl cert PHP.

, .

APNS. , . - Apple:

APN . APN . , APN .

, .

0

Urban Airship - . API http://urbanairship.com/docs/push_index.html , - .

( )

-1
source

All Articles