rubberbird / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

Javapns Notifications SSL Exceptions and Closed Sockets #238

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.public class PushTestClass2 {

    public void pushMessage() {
        ApnsService service = null;
        try {
            // get the certificate
            // ~/Desktop/CertKey.pem
            InputStream certStream = this.getClass().getClassLoader().getResourceAsStream("/opt/cert/CertKey.pem");
            service = APNS.newService().withCert(certStream, "PasswordHere").withSandboxDestination().build();
            service.start();
                try {
                    // so that we get the number of updates to display it as the badge.
                    PayloadBuilder payloadBuilder = APNS.newPayload();
                    payloadBuilder = payloadBuilder.badge(44).alertBody("some message you want to send here");
                    // check if the message is too long (it won't be sent if it is) 
                    //and trim it if it is.
                    if (payloadBuilder.isTooLong()) {
                        payloadBuilder = payloadBuilder.shrinkBody();
                    }
                    String payload = payloadBuilder.build();
                    String token = "DeviceTokenToSendNotificationToGoesHere";
                    service.push(token, payload);
                } catch (Exception ex) {
                    // some logging stuff
                }
        } catch (Exception ex) {
            // more logging
        } finally {
            // check if the service was successfull initialized and stop it here, if it was
            if (service != null) {
                service.stop();
            }

        }
    }
}
2.
3.

What is the expected output? What do you see instead?
Expect Notification to be sent through to device, but get SSL exceptions 
instead.

What version of the product are you using? On what operating system?
JDK 7 and APNS 0.2.3 Maven Wildfly 8.2. MAC OSX

Please provide any additional information below.

I have tested connecting with the certificates using OPENSSL and the 
certificates check out fine.

I understand this is an INFO error: 

14:37:54,419 INFO  [com.notnoop.apns.internal.ApnsConnectionImpl] (Thread-2044) 
Exception while waiting for error code: javax.net.ssl.SSLException: Connection 
has been shutdown: javax.net.ssl.SSLHandshakeException: Remote host closed 
connection during handshake
    at sun.security.ssl.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1476) [jsse.jar:1.7.0_60-ea]
    at sun.security.ssl.AppInputStream.read(AppInputStream.java:103) [jsse.jar:1.7.0_60-ea]
    at java.io.InputStream.read(InputStream.java:101) [rt.jar:1.7.0_60-ea]
    at com.notnoop.apns.internal.ApnsConnectionImpl$1MonitoringThread.run(ApnsConnectionImpl.java:114) [apns-0.2.3.jar:]
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection 
during handshake

Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at sun.security.ssl.InputRecord.read(InputRecord.java:482) [jsse.jar:1.7.0_60-ea]
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927) [jsse.jar:1.7.0_60-ea]
    ... 79 more

14:37:57,006 INFO  [com.notnoop.apns.internal.ApnsConnectionImpl] (Thread-2045) 
Exception while waiting for error code: java.net.SocketException: Socket is 
closed

Th Error in JBOSS LOG: 

14:37:59,158 ERROR [com.notnoop.apns.internal.ApnsConnectionImpl] (EJB default 
- 3) Couldn't send message after 3 retries.Message(Id=1; 
Token=54376E33446287C71DD37BCDE7A252A89838CDCFA97617B51223D07BBB5020C0; 
Payload={"aps":{"alert":"some message you want to send here","badge":44}}): 
javax.net.ssl.SSLHandshakeException: Remote host closed connection during 
handshake

Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at sun.security.ssl.InputRecord.read(InputRecord.java:482) [jsse.jar:1.7.0_60-ea]
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927) [jsse.jar:1.7.0_60-ea]
    ... 79 more

I have been on this for 4 days to no avail. ANY indication in the right path 
would be greatly appreciated!

Ty in advance.

Original issue reported on code.google.com by hairman_...@yahoo.com on 21 Apr 2015 at 1:05

GoogleCodeExporter commented 8 years ago
Issue has been resolved. Turns out i was using a Production profile with 
Development certificates.

Sorry for any inconvenience this may have caused! 

Original comment by hairman_...@yahoo.com on 23 Apr 2015 at 12:09

GoogleCodeExporter commented 8 years ago
Can you explain, how you had resolved the problem

Original comment by kottamak...@gmail.com on 14 Aug 2015 at 4:50