question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

not able to send push notifications because javax.net.ssl.SSLHandshakeException

See original GitHub issue

I am using maven dependency to include this library <dependency> <groupId>com.notnoop.apns</groupId> <artifactId>apns</artifactId> <version>1.0.0.Beta6</version> </dependency>

Java version: J2SE-1.5

Code is pretty basic:

   public static void main( String[] args )
   {
          ApnsService service =
            APNS.newService()
            .withCert("absolute-path-to-file.p12"
                    , "password")
            .withSandboxDestination()
            .build();
    String payload = APNS.newPayload().alertBody("Can't be simpler than this!").build();
    String token = "some token"; 

    service.start();
    service.push(token, payload);
    service.stop();
}

I am getting following stacktrace:

Exception in thread “main” com.notnoop.exceptions.NetworkIOException: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at com.notnoop.apns.internal.Utilities.wrapAndThrowAsRuntimeException(Utilities.java:284) at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:342) at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:312) at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46) at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:56) at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36) at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:45) at Apple.ApplePushNeetloopsAPNS.App.main(App.java:25) Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:953) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332) at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:709) at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:122) at java.io.OutputStream.write(OutputStream.java:75) at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:328) … 6 more Caused by: java.io.EOFException: SSL peer shut down incorrectly at sun.security.ssl.InputRecord.read(InputRecord.java:482) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:934) … 11 more

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:9

github_iconTop GitHub Comments

9reactions
shows19commented, Sep 25, 2015

i was also getting the same error and i tried Pusher which correctly sent the notification but then i figured out what is the issue.

The method i used to generate .p12 from my production certificate was wrong. i was selecting both Certificate and Key and then right click to export 2 files to generate .p12 file. Which infact was wrong and increasing file size. i regenerated .p12 file by right clicking only the production certificate and Voila!!! it worked.

On the other hand why pusher was working was due to the fact that pusher was using the certificate directly and not the generated .p12 file.

Hope this helps

0reactions
JiboStorecommented, Jan 26, 2017

I have tried this, but it is still the same error… NWPusher works though. Did you right click on the certificate or the private key? I remembered trying all 3 combinations, export the certificate, the private key, both cert and private key…

The complete error is always: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot send push notifications using Javapns/Javaapns SSL ...
I am a new iOS developer and I had the same issue before. I finally found that the problem was due to the...
Read more >
Push Notification is not working - Fails with a SSL handshake ...
PushNotificationService(90) -> Failed to notify device. javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX ...
Read more >
Push notification is failing for Android devices - Entrust
When sending push notifications to Android Devices an error is returned. Devices logs show the following error when connecting to the Transaction Service:...
Read more >
PI78502: DOC: SSLHANDSHAKEEXCEPTION OCCURS ...
Conponents affected: Foundation Server / Push Notifications Versions of IBM JDK 1.8 earlier than version 8.0.3.11 contain critical SSL issues that can cause...
Read more >
Handshake_failure exception when t… - Apple Developer
Handshake_failure exception when trying to push notification using APNS ... We are not sure if using 2 Macbooks that cause the issue. ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found