Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception : javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake #32

Closed
GoogleCodeExporter opened this issue Apr 27, 2015 · 16 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1.public class IphoneNotificationManager {

    public static void sentMessage(NotificationDetail notificationDetail) {
        PayLoad aPayload = payLoadValueOf(notificationDetail);

        PushNotificationManager pushManager = PushNotificationManager
                .getInstance();
        // Get iPhone client
        try {
            pushManager.addDevice(notificationDetail.getDeviceId(),
                    notificationDetail.getUuid());

            Device client = pushManager.getDevice(notificationDetail
                    .getDeviceId());
            // Send message
            pushManager.sendNotification(client, aPayload);

            System.out.println("Message sent! " + aPayload);
            System.out.println("# of attempts: "
                    + pushManager.getRetryAttempts());
            pushManager.removeDevice(notificationDetail.getDeviceId());
        } catch (Exception e) {
            System.out.println("exception : " + e);
            e.printStackTrace();
        }
    }

    public static void initializeConnection() {
        PushNotificationManager pushManager = PushNotificationManager
                .getInstance();
        // Initialize connection
        try {
            pushManager.initializeConnection(ApplicationProperties.APPLE_HOST,
                    ApplicationProperties.APPLE_PORT,
                    ApplicationProperties.CERTIFICATE_FILE_PATH,
                    ApplicationProperties.APPLE_PWD,
                    SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);
            System.out.println("connection establishd to APNS");
        } catch (Exception e) {
            System.out.println("not able to initialize connection to APNS");
        }
    }

    public static void stopConnection() {
        PushNotificationManager pushManager = PushNotificationManager
                .getInstance();
        try {
            pushManager.stopConnection();
            System.out.println("connection stopped succesfully");
        } catch (IOException e) {
            System.out.println("not able to stop connection to APNS");
        }
    }

    private static PayLoad payLoadValueOf(NotificationDetail notificationDetail) {
        PayLoad aPayload = null;
        try {
            aPayload = new PayLoad();
            aPayload.addAlert(notificationDetail.getMatchbetween() + " at "
                    + notificationDetail.getMatchdate() + " on "
                    + notificationDetail.getMatchtime());
            aPayload.addSound("default");

        } catch (JSONException e) {
            System.out.println("Exceptio : " + e);
        }
        return aPayload;
    }

    public static void main(String args[]) {
        NotificationDetail notificationDetail = new NotificationDetail();
        notificationDetail
                .setUuid("ebbf8c927bfd6754348fb7ccf17cbe73f2e4741fc10f08fc2316ae877867eb80");
        notificationDetail.setMatchbetween("abc vs axy");
        notificationDetail.setDeviceId("1");
        notificationDetail.setMatchdate("today ");
        notificationDetail.setMatchtime("12:30");
        initializeConnection();
        IphoneNotificationManager.sentMessage(notificationDetail);
        stopConnection();
    }

}

2. Working fine on Window 7 but not working in linux server.

What is the expected output? What do you see instead?
Getting an exception 
exception : javax.net.ssl.SSLHandshakeException: Remote host closed connection 
during handshake
javax.net.ssl.SSLHandshakeException: Remote host closed connection during 
handshake
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:801)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1089)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:618)
    at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
    at java.io.OutputStream.write(OutputStream.java:58)
    at javapns.back.PushNotificationManager.sendNotification(Unknown Source)
    at com.src.IphoneNotificationManager.sentMessage(IphoneNotificationManager.java:29)
    at com.src.PushJob.execute(PushJob.java:20)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:333)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:782)
    ... 9 more

What version of the product are you using? On what operating system?
Using 
bcprov-jdk15-145.jar
javapns-jdk1.5-v1.6.2.jar

Please provide any additional information below.

Original issue reported on code.google.com by cery...@gmail.com on 14 Oct 2010 at 8:32

@GoogleCodeExporter
Copy link
Author

When you:
Enable SSL logging in java by adding the following to your java VM arguments:

-Djavax.net.debug=all

What SSL errors do you get?

Original comment by idbill.p...@gmail.com on 16 Oct 2010 at 9:34

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

It works fine when we restart the tomcat server.

It appears again after sometime. Any help would be appreciated

Original comment by cery...@gmail.com on 19 Oct 2010 at 1:36

@GoogleCodeExporter
Copy link
Author

Sounds like you are trying to maintain a socket connection or running into the 
200 message limit that others have commented on. 

Would you verify?

Original comment by idbill.p...@gmail.com on 19 Oct 2010 at 4:11

@GoogleCodeExporter
Copy link
Author

I tried sending around 300 push in a loop and they all are successful.

This above piece of code is called by a scheduled job through quartz. 
It works fine for 2-3 hrs. But after that starts giving this exception, 
everything
resolves after we restart the server.




Original comment by cery...@gmail.com on 20 Oct 2010 at 11:27

@GoogleCodeExporter
Copy link
Author

Sounds like you are trying to maintain a socket connection.

The error is: Remote host closed connection during handshake

which would indicate that connection lapsed or you're not initializing the 
connection properly.

Original comment by idbill.p...@gmail.com on 20 Oct 2010 at 5:21

@GoogleCodeExporter
Copy link
Author

I am calling above methods in this order

1. initializeConnection();
2. sentMessage(notificationDetail);
3. stopConnection();

But exception is coming in 2. call when we use sendNotification method of 
PushNotificationManager instance. 

I even tried with not calling 3. stopConnection as mentioned in some threads 
which i found. But that is also of no help. I am receiving same exception. 

I am not able to find any clue at all why this is happening??

Original comment by cery...@gmail.com on 21 Oct 2010 at 5:12

@GoogleCodeExporter
Copy link
Author

It appears the getInstance is not syncronized. I'm updating the code to handle 
this.

Basically, when you call calling PushNotificationManager.getInstance you are 
getting a different instance of the singleton.

At the moment you would be better off having a class variable that stores that 
instance, so that you are guarnteed to get the same instance back.

Or you can try the new 163 version I just uploaded and provide feedback.

Original comment by idbill.p...@gmail.com on 21 Oct 2010 at 7:10

  • Changed state: Started

@GoogleCodeExporter
Copy link
Author

Thanks for that i'll try that and update you on this.......

Original comment by cery...@gmail.com on 22 Oct 2010 at 5:14

@GoogleCodeExporter
Copy link
Author

I tried getting instance only once. But same error occurred again after some 
tries.

Original comment by cery...@gmail.com on 22 Oct 2010 at 1:25

@GoogleCodeExporter
Copy link
Author

I was receiving the same javax.net.ssl.SSLHandshakeException exception and I 
solve this issue by removing all duplicates of org.json.JSONObject classes from 
my project (refactoring some packages helped ie org.json -> 
org.json.myframework). Javapns and otherframework included same org.json 
package with same class names within them - so that was the problem in my case 
- JAR hell :(

If you use Eclipse try Ctrl+Shift+T <JSONObject> to check for duplications.

Original comment by nikola.p...@gmail.com on 28 Nov 2010 at 11:56

@GoogleCodeExporter
Copy link
Author

Thanks for replying.

I have checked that also, but there is no duplication of jars for 
org.json.JSONObject classes. There exist only one jar for these classes i.e. 
javapns-jdk1.5-v1.6.2.jar.

Regards

Original comment by cery...@gmail.com on 29 Nov 2010 at 5:18

@GoogleCodeExporter
Copy link
Author

hi, I' getting the same error, please help me out

javax.net.ssl.SSLHandshakeException: Remote host closed connection during 
handshake
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:808)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1120)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
        at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
        at java.io.OutputStream.write(OutputStream.java:58)
        at com.apple.ist.retail.pos.tr.protocol.tr.transport.Call.executeCall(Call.java:197)
        at com.apple.ist.retail.pos.tr.protocol.tr.transport.Transport.executeCall(Transport.java:210)
        at com.apple.ist.retail.pos.tr.protocol.tr.TenderRetailServiceImpl.authorizeDebitPurchase(TenderRetailServiceImpl.java:486)
        at com.extendyourstore.domain.manager.tenderauth.tenderretail.TRAuthTechnician.requestAuthorization(TRAuthTechnician.java:943)
        at com.extendyourstore.domain.manager.tenderauth.TenderAuthValet.execute(TenderAuthValet.java:107)
        at com.extendyourstore.domain.manager.tenderauth.tenderretail.TRAuthTechnician.transport(TRAuthTechnician.java:1066)
        at com.extendyourstore.domain.manager.tenderauth.NxsTenderAuthManager.transportValet(NxsTenderAuthManager.java:283)
        at com.extendyourstore.domain.manager.tenderauth.NxsTenderAuthManager.requestAuthorization(NxsTenderAuthManager.java:172)
        at com.extendyourstore.pos.services.tender.authorization.can.AuthorizeChargeSite.arrive(AuthorizeChargeSite.java:587)
        at com.extendyourstore.foundation.tour.engine.Site.arrive(Site.java:177)
        at com.extendyourstore.foundation.tour.engine.Road.traverseForward(Road.java:833)
        at com.extendyourstore.foundation.tour.engine.Road.traverse(Road.java:582)
        at com.extendyourstore.foundation.tour.engine.SiteVertex.driveSite(SiteVertex.java:285)
        at com.extendyourstore.foundation.tour.engine.AbstractSite.driveSite(AbstractSite.java:71)
        at com.extendyourstore.foundation.tour.engine.Site.driveSite(Site.java:153)
        at com.extendyourstore.foundation.tour.service.BusDriver.processLetter(BusDriver.java:315)
        at com.extendyourstore.foundation.tour.service.BusDriver.processLetters(BusDriver.java:213)
        at com.extendyourstore.foundation.tour.service.AbstractCrewMember.run(AbstractCrewMember.java:231)
        at com.extendyourstore.foundation.manager.thread.StaticCacheThread.run(StaticCacheThread.java:148)
Caused by: java.io.EOFException: SSL peer shut down incorrectly

Original comment by sathiyar...@gmail.com on 17 Apr 2011 at 3:44

@GoogleCodeExporter
Copy link
Author

My guess is that you are not connecting to the correct host and/or port.

What troubleshooting have you done

Original comment by idbill.p...@gmail.com on 17 Apr 2011 at 4:30

@GoogleCodeExporter
Copy link
Author

ceryash, were you able to fix the issue you reported?

Original comment by sype...@gmail.com on 9 Sep 2011 at 7:05

@GoogleCodeExporter
Copy link
Author

Closing issue as no feedback was received by original poster for many months.  
Please feel free to re-open if the issue is still valid.

Original comment by sype...@gmail.com on 14 Sep 2011 at 4:08

  • Changed state: Invalid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant