Javapns 问题 - 卡在 PushManager.sendNotification( client, aPayload ); 上功能

发布于 2024-11-25 17:36:12 字数 5132 浏览 1 评论 0原文

每次我尝试发送通知时

都会出现以下错误: 连接已初始化... 尝试失败...重试 预收盘 终于在 在此处输入代码java.net.SocketException:套接字已关闭 在 com.sun.net.ssl.internal.ssl.SSLSocketImpl.checkEOF(来源未知) 在 com.sun.net.ssl.internal.ssl.AppInputStream.read(来源未知) 在 sun.nio.cs.StreamDecoder.readBytes(来源未知) 在 sun.nio.cs.StreamDecoder.implRead(来源未知) 在 sun.nio.cs.StreamDecoder.read(来源未知) 在 java.io.InputStreamReader.read(来源未知) 在 java.io.BufferedReader.fill(来源未知) 在 java.io.BufferedReader.readLine(来源未知) 在 java.io.BufferedReader.readLine(来源未知) 在 ts.javapns.back.PushNotificationManager.sendNotification(PushNotificationManager.java:199) 在 org.apache.jsp.japnslist_jsp._jspService(org.apache.jsp.japnslist_jsp:118) 在 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 在org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) 在org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) 在 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 在 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) 在 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) 在 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) 在 org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) 在 org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) 在 org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(未知来源)

enter code here

您使用的产品版本是什么?在什么操作系统上? Windows XP,最新版本的 javaapns

    // 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 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();          
} 

据我所知,此时我在 PushNotificationManager.java 文件

功能中遇到了问题: public void sendNotification(Device device, PayLoad Payload)

在 sendNotification 的这一行: this.socket.getOutputStream().write(getMessage(device.getToken(), new PayLoad() ));

但不知道socket是关闭的,为什么会这样?

请帮忙。

Everytime I try to send a notification

Get the following error:
Connection initialized...
Attempt failed... trying again
preclose
in finally
enter code herejava.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)

enter code here

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

    // 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 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();          
} 

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?

Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一念一轮回 2024-12-02 17:36:12

JavaPNS 最近更新至 2.0,并修复了截至发布日期报告的所有问题。它确实解决了您所描述的问题。

西尔万

JavaPNS was recently updated to 2.0, and fixed ALL reported issues up to the release date. It does fix the issue you are describing.

Sylvain

海之角 2024-12-02 17:36:12

我们是否必须为 AdHoc 指定用于开发的 sanbox 服务器或生产服务器?

Don't we have to specify the sanbox server for development or production server for the AdHoc?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文