我正在使用Smack API连接到Openfire服务器。我已经成功地创建了用户和登录用户,我的问题是我无法使用XMPPConnection.disconnect()
进行注销工作,此后,在创建帐户或登录其他用户时,会显示以下错误。有没有人在这种情况下使用过Smack API?
当尝试登录相同或其他用户时,该应用会收到此错误:
java.net.SocketException: Socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:146)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:312)
at sun.security.ssl.InputRecord.read(InputRecord.java:350)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:818)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:775)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:94)
at com.jcraft.jzlib.ZInputStream.read(ZInputStream.java:94)
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)
java.io.IOException: Stream closed
at java.io.BufferedWriter.ensureOpen(BufferedWriter.java:115)
at java.io.BufferedWriter.write(BufferedWriter.java:220)
at java.io.Writer.write(Writer.java:157)
at org.jivesoftware.smack.PacketWriter.writePackets(PacketWriter.java:192)
at org.jivesoftware.smack.PacketWriter.access$000(PacketWriter.java:40)
at org.jivesoftware.smack.PacketWriter$1.run(PacketWriter.java:76)
Exception in thread "Smack Packet Reader (0)" java.lang.NullPointerException
at org.jivesoftware.smack.XMPPConnection.shutdown(XMPPConnection.java:380)
at org.jivesoftware.smack.PacketReader.notifyConnectionError(PacketReader.java:166)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:332)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
答案 0 :(得分:3)
在尝试第二次登录之前,请再次尝试呼叫connect
:一旦您致电disconnect
注销实际套接字已关闭。 connect
应该重新打开它。