以下是我在研究asmack4.0出现的异常
06-17 12:02:56.924: W/System.err(10622): org.jivesoftware.smack.SmackException$ConnectionException
06-17 12:02:56.924: W/System.err(10622): at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPC onnection.java:431)
06-17 12:02:56.940: W/System.err(10622): at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:799)
06-17 12:02:56.940: W/System.err(10622): at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:391)
06-17 12:02:56.940: W/System.err(10622): at com.example.testchat.MainActivity.test(MainActivity.java:121)
06-17 12:02:56.940: W/System.err(10622): at com.example.testchat.MainActivity.access$0(MainActivity.java:56)
06-17 12:02:56.940: W/System.err(10622): at com.example.testchat.MainActivity$1.run(MainActivity.java:34)
06-17 12:02:56.940: W/System.err(10622): at java.lang.Thread.run(Thread.java:856)
找了各种办法也没能解决,最后无意中发现了这个
connectionConfig = new ConnectionConfiguration(
loginConfig.getXmppHost(), loginConfig.getXmppPort(),
loginConfig.getXmppServiceName());
connectionConfig.setSecurityMode(SecurityMode.enabled);
安全模式,对没错。就是安全模式导致认证失败于是我把它改为了disabled。问题攻克了
还有就是在主线程中不能直接登录,否则也会报这个错