iOS push notification
由于handshake_failure
而失败,但它在我的本地计算机上工作正常,并且在服务器上部署时出错。
我正在使用apns-0.1.5.jar
代码:
static
{
service = APNS.newService()
.withCert(ClassLoader.class.getResourceAsStream("cert.p12"), "pwd")
.withSandboxDestination()
.build();
}
public static void pushMSG(String msg,String deviceToken)
{
String payload = APNS.newPayload().alertBody(msg).build();
AppLog.info("Message : "+msg+", deviceToken "+deviceToken);
service.push(deviceToken, payload);
}
错误日志
com.notnoop.exceptions.NetworkIOException: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
com.notnoop.apns.internal.Utilities.wrapAndThrowAsRuntimeException(Utilities.java:268)
com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:173)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:52)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
com.gcash.notification.APNSManager.pushMSG(APNSManager.java:35)
com.gcash.TestServlet.doGet(TestServlet.java:58)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1720)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:954)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:632)
答案 0 :(得分:1)
我遇到了同样的问题,我通过以下步骤解决了这个问题。
希望它有效。