views:

19

answers:

0

Hi all !

I'm trying to push my app not in developpement, and i get the following error :

stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.push.apple.com:2195

To push i use :

    $serverId=1;
 $name="NameOfMyApp";
 $apnsHost = 'gateway.push.apple.com';
 $apnsPort = 2195;
 $apnsCert = 'ck.pem';
 //$payload['aps'] = array('alert' => $msg, 'badge' => $badge, 'sound' => 'default');
 $payload['aps'] = array('badge' => $badge);
 $payload['server'] = array('serverId' => $serverId, 'name' => $name);
 $output = json_encode($payload);
 $streamContext = stream_context_create();
 stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
 $apns = stream_socket_client('ssl://'.$apnsHost.':'.$apnsPort,$error,$errorString,2,STREAM_CLIENT_CONNECT,$streamContext);
 $apnsMessage = chr(0).chr(0).chr(32).pack('H*',str_replace(' ','',$token)).chr(0).chr(strlen($output)).$output;
 fwrite($apns, $apnsMessage);
 fclose($apns);

I do not know where the problem is, if someone can help me. I have my App signed with the Production Cert, my Cert.pem on my serv has been made on a Mac. Do not know what to do, everything was ok on dev.