关于安卓6.0.1系统Xmpp不能链接的问题!“No response from the server”

    今天客户在用程序的时候发现安卓6.0.1的程序死活不能登陆,但是获取版本号或者在6.0以下的手机上时没问题的! 看了下是xmpp链接除了问题,查了查发现当登陆的时候会出现“No response from the server”!

       发现:

XMPPConnection connection = new XMPPConnection(getConfig(xmppPort));
connection.connect();返回是链接成功的;
    然后发现“No response from the server”出现在2个地方:
     1:
          IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
          if (response == null) {
              throw new XMPPException("No response from the server.");
          }
     2: Bind response = (Bind) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        collector.cancel();
         if (response == null) {
             throw new XMPPException("No response from the server.");
         }


             IQ ack = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
             collector.cancel();
             if (ack == null) {
                 throw new XMPPException("No response from the server.");
             }
    所以resource bind失败,或者确实没有收到response包。smack又是一个封装的库,参数只有用户名,密码和SecurityMode了。所有最后发现问题出现在了TLS链路上。所以改了下默认的enable为disable,问题立即解决,虽说安全系数下降,但是找了好久只有找到这个方法了。如果你们有好的方法,可以给我留言啊!
       最后贴上修改后的代码:
   ConnectionConfiguration config = new ConnectionConfiguration(GlobalConstant.XMPPServerName, Integer.valueOf(xmppPort));
    config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);//这是要修改的部门,上边只是实例。

    

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值