imnimit / javapns

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

stuck on pushManager.sendNotification( client, aPayload ); #58

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Everytime I try to send a notification

What is the expected output? What do you see instead?
Expected to send a notification to ipod/iphone? 

Get the following error:
Connection initialized...
Attempt failed... trying again
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 ts.javapns.back.PushNotificationManager.sendNotification(PushNotificationManager.java:199)
    at org.apache.jsp.japnslist_jsp._jspService(org.apache.jsp.japnslist_jsp:118)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)

What version of the product are you using? On what operating system?
Windows XP, newest version of javaapns

Please provide any additional information below.
 // APNs Server Host & port      
 String HOST = "gateway.sandbox.push.apple.com";      
 int PORT = 2195;      
 // Badge      
 int BADGE = 6;      
 // iPhone's UDID (64-char device token)      
 String iPhoneId = "aebf53cc8d6bfaf47dace40747091fa5b0fc837b...";      

 String certificate = "C:/webapplication/WEB-INF/cert.p12";      
 String passwd = "password";  

 System.out.println( "Setting up Push notification" ); 

 //Set system properties .....
 System.setProperty("javax.net.ssl.trustStore", "/var/www/apns/<apple.keystore>"); 

 System.setProperty("javax.net.ssl.trustStorePassword", "<pass>"); 

try {              
  // Setup up a simple message              
  PayLoad aPayload = new PayLoad();              
  aPayload.addBadge( BADGE );              
  System.out.println( "Payload setup successfull." );              
  System.out.println ( aPayload );              

  // Get PushNotification Instance              
  PushNotificationManager pushManager = PushNotificationManager.getInstance();       

  System.out.println( "Linking iPhone's UDID (64-char device token) to a stringName" );  

  // Link iPhone's UDID (64-char device token) to a stringName              
  pushManager.addDevice("iPhone", iPhoneId);              
  System.out.println( "iPhone UDID taken." );              
  System.out.println( "Token: " + pushManager.getDevice( "iPhone" ).getToken() );              

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

  // Initialize connection              
  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!" ); 

    //Remove device
  pushManager.removeDevice(iPhoneId); 
  System.out.println( "Removing Device" );

  System.out.println( "# of attempts: " + pushManager.getRetryAttempts() );              
  pushManager.stopConnection();              
  System.out.println( "done" );          
} catch (Exception e) {              
  e.printStackTrace();          
} 

Please help.

Original issue reported on code.google.com by sguerr...@gmail.com on 23 Jul 2011 at 8:51

GoogleCodeExporter commented 8 years ago
As far as I can tell I am having an issue at this point in 
PushNotificationManager.java file

Function:
public void sendNotification(Device device, PayLoad payload) 

at this line of sendNotification:
this.socket.getOutputStream().write(getMessage(device.getToken(), new PayLoad() 
));

Socket is closed but I do not know why it would be?

Original comment by sguerr...@gmail.com on 23 Jul 2011 at 9:56

GoogleCodeExporter commented 8 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:36

GoogleCodeExporter commented 8 years ago
Thanks idbill... I finally got ti to work! and again sorry for sending you an 
email out of the blue... but thanks again!

Original comment by sguerr...@gmail.com on 28 Jul 2011 at 12:19

GoogleCodeExporter commented 8 years ago

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