使用notnoop / java-apns发送消息:消息已经发送……但是我得到了一些错误

时间:2021-09-26 01:43:03

using notnoop / java-apns https://github.com/notnoop/java-apns I'm using this code to send message:

使用notnoop/java-apns https://github.com/notnoop/java-apns,我使用此代码发送消息:

try {
ApnsService service = APNS
.newService()
.withCert("myCertificates.p12",
"xxxxxxxxxx").withProductionDestination().build();

        String payload = APNS.newPayload().alertBody(messageObject.MsgText)
                .sound("default").badge(1).build();

        Iterator<String> vItr = messageObject.addresses.iterator();
        while (vItr.hasNext()) {
            String sent2Token = (String) (vItr.next());

            service.push(sent2Token, payload);
        }
        service.stop();

    } catch (NetworkIOException e) {
        System.out.println("client>> " + e.getMessage());
        e.printStackTrace();
    }

message is sent fine, but need to get red of this output, because it might slow my program beside it taking space .... please advice?

消息发送好,但是需要红色的输出,因为它可能会减缓我的程序在采取空间....请建议吗?

16:07:56.206 [Thread-4140] INFO c.n.apns.internal.ApnsConnectionImpl - Exception while waiting for error code
java.net.SocketException: Socket closed
at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.7.0_05]
at java.net.SocketInputStream.read(SocketInputStream.java:150) ~[na:1.7.0_05]
at java.net.SocketInputStream.read(SocketInputStream.java:121) ~[na:1.7.0_05]
at sun.security.ssl.InputRecord.readFully(InputRecord.java:312) ~[na:1.7.0_05]
at sun.security.ssl.InputRecord.read(InputRecord.java:350) ~[na:1.7.0_05]
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:893) ~[na:1.7.0_05]
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:850) ~[na:1.7.0_05]
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102) ~[na:1.7.0_05]
at java.io.InputStream.read(InputStream.java:101) ~[na:1.7.0_05]
at com.notnoop.apns.internal.ApnsConnectionImpl$1MonitoringThread.run(ApnsConnectionImpl.java:122) ~[server.jar:na]

1 个解决方案

#1


1  

To resurrect a year old question:

复兴一年前的问题:

Until recently java-apns logged an exception when the connection with the apns service was closed. You should do two things:

直到最近,当与apns服务的连接被关闭时,java-apns记录了一个异常。你应该做两件事:

  • Use java-apns 1.0.0 Beta2 (available on maven central) which does not log that exception
  • 使用java-apns 1.0.0 Beta2(可以在maven central上使用),它不会记录该异常
  • Normally you'd keep the built ApnsService around during the runtime of your server as setting up and closing down the SSL connection is a little expensive. So only close it if you're sure that you won't send another connection for a long time. ApnsService mantains a live connection with the Apple's push server.
  • 通常,在服务器的运行时,您应该保留构建的ApnsService,因为设置和关闭SSL连接有点贵。所以,只有当你确定在很长一段时间内不会发送另一个连接时,才关闭它。ApnsService具有与苹果的push服务器的实时连接。

#1


1  

To resurrect a year old question:

复兴一年前的问题:

Until recently java-apns logged an exception when the connection with the apns service was closed. You should do two things:

直到最近,当与apns服务的连接被关闭时,java-apns记录了一个异常。你应该做两件事:

  • Use java-apns 1.0.0 Beta2 (available on maven central) which does not log that exception
  • 使用java-apns 1.0.0 Beta2(可以在maven central上使用),它不会记录该异常
  • Normally you'd keep the built ApnsService around during the runtime of your server as setting up and closing down the SSL connection is a little expensive. So only close it if you're sure that you won't send another connection for a long time. ApnsService mantains a live connection with the Apple's push server.
  • 通常,在服务器的运行时,您应该保留构建的ApnsService,因为设置和关闭SSL连接有点贵。所以,只有当你确定在很长一段时间内不会发送另一个连接时,才关闭它。ApnsService具有与苹果的push服务器的实时连接。