PDA

View Full Version : Having problems with production push




Jeremy1026
Jun 23, 2009, 10:40 AM
Hey guys. I am working on an app that implements push. It works great in development mode connecting to the sandbox servers, but it just doesn't play nice with the production servers.

I am using the following PHP code to do the actual pushing.


function pushiPhoneMessage($token,$message) {

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', './production1.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', 'thepass');
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx); //gateway.sandbox.push.apple.com, port 2195 for development

if(!$fp) {
print "Failed to connect $err $errstr\n";
} else {
$payload = json_encode($message);
//echo $token." > ".$payload."<br/>";

$msg = chr(0) . chr(0) . chr(32) . pack('H*',str_replace(' ', '', $token)) . chr(0) . chr(strlen($payload)) . $payload;
fwrite($fp, $msg);

}
fclose($fp);
}

I have the correct password for the certificate in the PHP, I have the certificate on my server, I can push fine using the same script but using sandbox. Can anyone provide any insight to make this work. It's the last step to a giant puzzle.



Jeremy1026
Jun 23, 2009, 01:08 PM
It was a problem with my build, it wasn't connecting to the push server.

notmaxx
Dec 2, 2009, 11:17 AM
Hi Jeremy,
I met the same problem, could you help on this, sandbox is ok but production push doesn't accept my certificate