Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-18-2009, 04:31 PM   #1 (permalink)
Registered Member
 
MikesTooLz's Avatar
 
Join Date: Jan 2009
Location: Miami, Florida
Posts: 211
Send a message via AIM to MikesTooLz
Default issues with PHP script Push Notification

the app is registering with the sandbox already and getting the token.
im trying a sample script to see if I can just get a test mssage to go through but I am getting the following error when the script is run.

Quote:
Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure in push.php on line 21

Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in push.php on line 21

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in push.php on line 21
Failed to connect 0

the script im usng is as follows:
Quote:
<?php
$deviceToken = 'XXXXXXXXXXXXXXXXXXXXXX'; // masked for security reason
// Passphrase for the private key (ck.pem file)
// $pass = '';
// Get the parameters from http get or from command line
$message = $_GET['message'];
$badge = (int)$_GET['badge'] or $badge = (int)$argv[2];
$sound = $_GET['sound'] or $sound = $argv[3];
// Construct the notification payload
$body = array();
$body['aps'] = array(’alert’ => $message);
if ($badge)
$body['aps']['badge'] = $badge;
if ($sound)
$body['aps']['sound'] = $sound;
/* End of Configurable Items */
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
// assume the private key passphase was removed.
// stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
print "Failed to connect $err $errstrn";
return;
}
else {
print "Connection OKn";
}
$payload = json_encode($body);
$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);
?>
MikesTooLz is offline   Reply With Quote
Old 07-18-2009, 06:07 PM   #2 (permalink)
Registered Member
 
MikesTooLz's Avatar
 
Join Date: Jan 2009
Location: Miami, Florida
Posts: 211
Send a message via AIM to MikesTooLz
Default

I got it working now to the point that it doesnt have any errors and it says the message was sent OK. however my devicenever recieves the message.
MikesTooLz is offline   Reply With Quote
Old 12-20-2009, 09:16 AM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

I'm getting the same error as in your original post. What did you do to solve it/did you work out what was causing the problem?

Tom
harrytheshark is offline   Reply With Quote
Old 12-28-2009, 05:15 PM   #4 (permalink)
Registered Member
 
dimix's Avatar
 
Join Date: Aug 2008
Location: Pisa, Italy
Posts: 23
Default

Same problem here.. how you have solved?

PS: from local is working, from my VPS server, is not working..
__________________
Dimitri Giani
Web Developer - iPhone Developer

My Apps:
-
Cheat Docs
Step Alarm
Calci Guide (Pisa)
Costituzione Italiana
Slide Space
dimix is offline   Reply With Quote
Old 09-17-2010, 08:46 AM   #5 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 1
Default

Quote:
Originally Posted by dimix View Post
Same problem here.. how you have solved?
I couldn't find any "fix" with a Google search, but I finally figured out what I did wrong so I thought I'd post it here for future reference.

The handshake failure is most likely related to your cert. You've either constructed it incorrectly, the script can't find the file. My mistake was my pathname was wrong (I was including my push notification php script from another directory, and the cert has to have a path from the calling script, not the include).
DrieStone is offline   Reply With Quote
Old 07-15-2011, 04:42 AM   #6 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 2
Default

Quote:
Originally Posted by MikesTooLz View Post
the app is registering with the sandbox already and getting the token.
im trying a sample script to see if I can just get a test mssage to go through but I am getting the following error when the script is run.




the script im usng is as follows:
change the port number from 2195 to 2196 as 2195 is for sending the req and 2196 is for getting the response
ronak28286 is offline   Reply With Quote
Old 07-15-2011, 04:43 AM   #7 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 2
Default

change the port number from 2195 to 2196 as 2195 is for sending the req and 2196 is for getting the response
ronak28286 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 267
17 members and 250 guests
ADY, Alsahir, dacapo, Dani77, Desert Diva, Duncan C, F_Bryant, Grinarn, HemiMG, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, smethorst, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,761
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:47 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0