Push Notification is not sent to apple devices

fatCop picture fatCop · Mar 18, 2015 · Viewed 7.9k times · Source

I'm using JavaPNS for sending push notification to apple devices. But it's not working. Code snippet from my app:

try {
    BasicConfigurator.configure();
    Push.alert("Hello World!", "D:\\myPushKeyStore.p12", "myPushKeyStorePass", false, "b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607");
}
catch (CommunicationException e) {
    e.printStackTrace();
}
catch (KeystoreException e) {
    e.printStackTrace();
}

Here is the error log:

1 [http-bio-8080-exec-9] DEBUG javapns.notification.Payload  - Adding alert [Hello World!]
464 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocketFactory
476 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocket to gateway.sandbox.push.apple.com:2195
987 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Initialized Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195]: 599efe20[SSL_NULL_WITH_NULL_NULL: Socket[addr=gateway.sandbox.push.apple.com/17.172.232.45,port=2195,localport=57282]]
995 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Building Raw message from deviceToken and payload
996 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Built raw message ID 1 of total length 77
996 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Attempting to send notification: {"aps":{"alert":"Hello World!"}}
996 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  -   to device: b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607
1574 [http-bio-8080-exec-9] INFO javapns.notification.PushNotificationManager  - Attempt failed (Remote host closed connection during handshake)... trying again
1574 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocket to gateway.sandbox.push.apple.com:2195
1842 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Attempting to send notification: {"aps":{"alert":"Hello World!"}}
1842 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  -   to device: b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607
2388 [http-bio-8080-exec-9] INFO javapns.notification.PushNotificationManager  - Attempt failed (Remote host closed connection during handshake)... trying again
2388 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocket to gateway.sandbox.push.apple.com:2195
2658 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Attempting to send notification: {"aps":{"alert":"Hello World!"}}
2658 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  -   to device: b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607
3217 [http-bio-8080-exec-9] ERROR javapns.notification.PushNotificationManager  - Attempt to send Notification failed and beyond the maximum number of attempts permitted
3220 [http-bio-8080-exec-9] ERROR javapns.notification.PushNotificationManager  - Delivery error
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake

Am I having any issue regarding keystore file?

Answer

fatCop picture fatCop · Mar 18, 2015

Finally I found that the problem was due to the p12 certificate which was causing SSL Handshake Error.
I refer to Cannot send push notifications using Javapns/Javaapns SSL handshake failure solution in getting the correct p12 file. Thanks!