我写了以下代码:
ConnectionConfiguration connConfig = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
XMPPConnection connection = new XMPPConnection(connConfig);
connection.connect();
System.in.read();
connection.login("xxx@gmail.com", "***"); //Exception occurs here!
例外是
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:185)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:282)
at sun.nio.cs.StreamDecoder.implRead (StreamDecoder.java:324)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:176)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:153)
at java.io.BufferedReader.read1(BufferedReader.java:204)
at java.io.BufferedReader.read(BufferedReader.java:278)
at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:2992)
at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046)
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1144)
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:325)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)Exception in thread "main" No response from the server.:
at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication.java:73)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:212)
at org.jivesoftware.smack.Connection.login(Connection.java:348)
有时我也会遇到这个异常:
Exception in thread "main" Connection failed. No response from server.:at org.jivesoftware.smack.PacketReader.startup(PacketReader.java:119)
at org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:568)
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:527)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:953)
有谁能够帮我?我用谷歌搜索了它,有人说如果你Thread.sleep(10000);
在连接和登录之间使用一些延迟就可以了。但它不起作用!