webpro2 / javapns

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

Socket Exception - javapns-jdk16-168.jar #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Following is the error I get on my windows machine :

Connection initialized...
preclose
in finally
java.net.SocketException: Socket is closed
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.checkEOF(Unknown Source)
    at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source)
    at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
    at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
    at sun.nio.cs.StreamDecoder.read(Unknown Source)
    at java.io.InputStreamReader.read(Unknown Source)
    at java.io.BufferedReader.fill(Unknown Source)
    at java.io.BufferedReader.readLine(Unknown Source)
    at java.io.BufferedReader.readLine(Unknown Source)
    at javapns.back.PushNotificationManager.sendNotification(Unknown Source)
    at Push.main(Push.java:62)

I am using the sample example provided :

 import javapns.back.PushNotificationManager;
 import javapns.back.SSLConnectionHelper;
 import javapns.data.Device;
 import javapns.data.PayLoad;

public class Push {

     private static final String HOST = "gateway.sandbox.push.apple.com";
     private static final int PORT = 2195;
     private static final int BADGE = 66;

     private static String iPhoneId = "my device id";
     private static String certificate = "APNS_SSLCertificate_Key.p12";      //Generating this as per http://code.google.com/p/javapns/wiki/GetAPNSCertificate

     private static String passwd = "1289";

    public static void main( String[] args ) throws Exception {
       try {
             PayLoad aPayload = new PayLoad();
             aPayload.addBadge( BADGE );

             PushNotificationManager pushManager = PushNotificationManager.getInstance();

             pushManager.addDevice("iPhone", iPhoneId);

             Device client = pushManager.getDevice( "iPhone" );
             System.out.println( "Client setup successfull." );

             pushManager.initializeConnection( HOST, PORT, certificate, passwd, SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);
             System.out.println( "Connection initialized..." );

            // Send message
             pushManager.sendNotification( client, aPayload );
             System.out.println( "Message sent!" );

            System.out.println( "# of attempts: " + pushManager.getRetryAttempts() );
             pushManager.stopConnection();

            System.out.println( "done" );

        } catch (Exception e) {
             e.printStackTrace();
         }
     }
 }

Original issue reported on code.google.com by dux.dee...@gmail.com on 20 Jul 2011 at 1:26

GoogleCodeExporter commented 9 years ago
Seems like a bad cert.

What does the SSL debugging show?

Original comment by idbill.p...@gmail.com on 25 Jul 2011 at 9:35

GoogleCodeExporter commented 9 years ago
Yup...it was a bad cert.
Problem solved, but my code is stuck up after printing "Connection 
initialized..."
Whatmay be the error ?

Thanks

Original comment by dux.dee...@gmail.com on 28 Jul 2011 at 10:27

GoogleCodeExporter commented 9 years ago
try the next version

Original comment by idbill.p...@gmail.com on 30 Aug 2011 at 7:59

GoogleCodeExporter commented 9 years ago
Fixed in 2.0 (see issue #54).

Original comment by sype...@gmail.com on 7 Sep 2011 at 4:29