0

JavaPNS用于向苹果设备发送推送通知。但它不起作用。我的应用程序中的代码片段:

try {
    BasicConfigurator.configure();
    Push.alert("Hello World!", "D:\\myPushKeyStore.p12", "myPushKeyStorePass", false, "b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607");
}
catch (CommunicationException e) {
    e.printStackTrace();
}
catch (KeystoreException e) {
    e.printStackTrace();
}

这是错误日志:

1 [http-bio-8080-exec-9] DEBUG javapns.notification.Payload  - Adding alert [Hello World!]
464 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocketFactory
476 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocket to gateway.sandbox.push.apple.com:2195
987 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Initialized Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195]: 599efe20[SSL_NULL_WITH_NULL_NULL: Socket[addr=gateway.sandbox.push.apple.com/17.172.232.45,port=2195,localport=57282]]
995 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Building Raw message from deviceToken and payload
996 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Built raw message ID 1 of total length 77
996 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Attempting to send notification: {"aps":{"alert":"Hello World!"}}
996 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  -   to device: b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607
1574 [http-bio-8080-exec-9] INFO javapns.notification.PushNotificationManager  - Attempt failed (Remote host closed connection during handshake)... trying again
1574 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocket to gateway.sandbox.push.apple.com:2195
1842 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Attempting to send notification: {"aps":{"alert":"Hello World!"}}
1842 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  -   to device: b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607
2388 [http-bio-8080-exec-9] INFO javapns.notification.PushNotificationManager  - Attempt failed (Remote host closed connection during handshake)... trying again
2388 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocket to gateway.sandbox.push.apple.com:2195
2658 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Attempting to send notification: {"aps":{"alert":"Hello World!"}}
2658 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  -   to device: b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607
3217 [http-bio-8080-exec-9] ERROR javapns.notification.PushNotificationManager  - Attempt to send Notification failed and beyond the maximum number of attempts permitted
3220 [http-bio-8080-exec-9] ERROR javapns.notification.PushNotificationManager  - Delivery error
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake

我对密钥库文件有任何问题吗?

4

1 回答 1

0

最后我发现问题是由于 p12 证书导致 SSL 握手错误。我在获取正确的 p12 文件时
参考了无法使用 Javapns/Javaapns SSL 握手失败解决方案发送推送通知。谢谢!

于 2015-03-18T07:18:13.513 回答