关于IOS推送,线程堵塞

wurendi123456 2012-11-15 01:23:35
	public void iospush(String token, String manager) throws Exception {
try {
// 从客户端获取的deviceToken
log.debug("Push Start deviceToken:" + token);
// 定义消息模式
PayLoad payLoad = new PayLoad();
payLoad.addAlert(manager);
payLoad.addSound("beep.wav");
// 注册deviceToken
PushNotificationManager pushManager = PushNotificationManager.getInstance();
pushManager.addDevice("iPhone", token);
// 连接APNS
pushManager.initializeConnection(host, port, certificatePath,certificatePassword,SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);
// 发送推送
Device client = pushManager.getDevice("iPhone");
pushManager.sendNotification(client, payLoad);
// 停止连接APNS
pushManager.stopConnection();
// 删除deviceToken
pushManager.removeDevice("iPhone");
log.debug("IOS Push End");
} catch (Exception ex) {
ex.printStackTrace();
}
}


是启动项目时,用线程启动这一方法,执行到这一句“pushManager.sendNotification(client, payLoad);”的时候,推送成功了,但卡在这里了。

public void sendNotification(Device paramDevice, PayLoad paramPayLoad)
throws UnrecoverableKeyException, KeyManagementException, KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, Exception
{
byte[] arrayOfByte = getMessage(paramDevice.getToken(), paramPayLoad);
int i = 0;
BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(this.socket.getInputStream()));
int j = 0;
while (i == 0)
try
{
logger.debug("Attempting to send Notification [" + paramPayLoad.toString() + "]");
j++;
this.socket.getOutputStream().write(arrayOfByte);
logger.debug("Flushing");
this.socket.getOutputStream().flush();
i = 1;
logger.debug("Notification sent");
while (!this.socket.isInputShutdown())
while (localBufferedReader.ready())
logger.debug("ready now");
}
catch (IOException localIOException)
{
if (j >= this.retryAttempts)
{
logger.error("Attempt to send Notification failed and beyond the maximum number of attempts permitted");
throw localIOException;
}
logger.info("Attempt failed... trying again");
try
{
this.socket.close();
}
catch (Exception localException)
{
}
this.socket = this.connectionHelper.getSSLSocket();
}
finally
{
logger.debug("in finally");
logger.debug("done");
this.socket.close();
}
}


查看jar源码,判断是在“while (!this.socket.isInputShutdown())
while (localBufferedReader.ready())
logger.debug("ready now");” 这段死循环了。

jar包是:javapns-jdk16-169.jar

求解决方法。
...全文
193 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2014-11-21
  • 打赏
  • 举报
回复
ios证书不对

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧