Unable to connect to live 'ssl://gateway.push.apple.com:2195'
Asked Answered
E

2

6

I am facing issue with APNS php code for push notification on IOS devices, I have two separate connection for Development and Production.

  1. I have configure the development connection on my server by adding the .pem file certificate and Passphares its working perfect and I received the notification also. Have a look my development configuration:

Url: 'ssl://gateway.sandbox.push.apple.com:2195'

$push = new ApnsPHP_Push(
    ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
    'APNS_Dev_ISAS.pem'
);
$myNewLogger = new MyNewLogger();
$push->setLogger($myNewLogger);

// Set the Provider Certificate passphrase
$push->setProviderCertificatePassphrase('1234567');

$push->setRootCertificationAuthority('APNS_Dev_ISAS.pem');
$push->connect();

Issue:

  1. Than I configured the connection for Production by adding following parameters but I getting the connection error:

Url: ssl://gateway.push.apple.com:2195

$push = new ApnsPHP_Push(
    ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION,
    'APNS_PROD_ISAS.pem'
);
$myNewLogger = new MyNewLogger();
$push->setLogger($myNewLogger);

// Set the Provider Certificate passphrase
$push->setProviderCertificatePassphrase('12345678');

$push->setRootCertificationAuthority('APNS_PROD_ISAS.pem');
$push->connect();

Error of connection: INFO: Trying ssl://gateway.push.apple.com:2195...ERROR: Unable to connect to 'ssl://gateway.push.apple.com:2195': (0) INFO: Retry to connect (1/3)...INFO: Trying ssl://gateway.push.apple.com:2195...ERROR: Unable to connect to 'ssl://gateway.push.apple.com:2195': (0) INFO: Retry to connect (2/3)... INFO: Trying ssl://gateway.push.apple.com:2195...ERROR: Unable to connect to 'ssl://gateway.push.apple.com:2195': (0) INFO: Retry to connect (3/3)... INFO: Trying ssl://gateway.push.apple.com:2195...ERROR: Unable to connect to 'ssl://gateway.push.apple.com:2195': (0)

I google the issue and I found the some solutions and I have check all and everything is fine but no success.

  • I have used the correct path for development and production.
  • I have created the separate certificate .pem files for both and tested the certificate on pusher app. Certificate are correct.
  • Port is also fine and no blocking from my server because same port is used in development url and development server push notification working fine.

Any help will be appreciated really. Thanks in advance.

Emmie answered 27/10, 2015 at 4:54 Comment(0)
E
6

Certificate (.pem) having issue that I was created for push notification.

Solution: After few days trying on same issue I found that create certificate with mini character passpharess may be 1234, It will work perfect for you and make successful connection to IOS push notification server.

May be this will help someone else.

Thanks.

Emmie answered 2/11, 2015 at 4:49 Comment(5)
omggg...... i was stuck for like 8 hrs until i found this answer.... i love you, saved me big time.... I wonder if the reason when a complex passphrase fails to connect, would the reason be because it is trying to do a 4 way handshake with the APNS server like ejabberd(like any other XMPP sockets) does, so if the SHA decryption/encryption takes longer than the timeout limit then it fails the connection.... i wonderHeidiheidie
@lffi, In my case I got .p12 file from another machine where i had generated .csr file. Now I have generated .pem file with the passphrase 1234 but it still giving me same error while creating VOIP test connection. Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known) This is I'm using to test online. Any suggestion what I'm missing ?Kinney
@Kinney bro , I too have the same situation, did you find any workaround? Please let me know.Ramshackle
I fixed by this way. Used "$ openssl pkcs12 -in cert.p12 -out pushcert.pem -nodes -clcerts" command to generate the pem. While its asked for "passpharess" I did not give any "passpharess" Just clicked on enter. and testd using "apns-gcm.bryantan.info" . Hope it will help someone.Ramshackle
@Ramshackle you saved my day. Thank you very much!Mantelpiece
D
0

I was getting same problem when I execute my PHP script. After some research, I commented these three key-pair values 'cafile', 'CN_match' and 'ciphers'.

Then its started working properly. I hope this reply become useful to any other person as well.

$contextOptions = array(
'ssl' => array(
    'verify_peer' => false, // You could skip all of the trouble by changing this to false, but it's WAY uncool for security reasons.
//    'cafile' => 'NiteVisionWebPushFile.pem',
//    'CN_match' => 'gateway.push.apple.com', // Change this to your certificates Common Name (or just comment this line out if not needed)
  //  'ciphers' => 'HIGH:!SSLv2:!SSLv3',
    'disable_compression' => true,
));
Dich answered 26/2, 2018 at 11:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.