Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple Push Notification is not working on my godaddy shared server, it's throght failed to connect 111 connection refused php push notification error

I got a error like failed to connect 111 connection refused php push notification using APNS. It's working fine on local server but not working on GoDaddy shared server.Please find my Php code.

$path_pem_file="http://dummy.com/uploads/app/1.pem";
// this is the pass phrase you defined when creating the key
$passphrase = '';
// this is where you can customize your notification
$payload = '{"aps":{"alert":"message","sound":"default"}}';

// start to create connection
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $path_pem_file);
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,   $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', 'Device token here..') . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));

if ($fp) {  fclose($fp);}
like image 959
Nikita Sarvaiya Avatar asked Nov 28 '25 23:11

Nikita Sarvaiya


1 Answers

You need to have following PORTs open on your server to use Apple APNs

2195
2196

As far as I know GoDaddy will not open this ports for you on shared hosting and you will have to go for Dedicated server or VPS.

like image 60
pinkal vansia Avatar answered Dec 01 '25 12:12

pinkal vansia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!