1
votes

I am using Smack API to connect to the Openfire server. I have successfully made it work to create user and login user, my problem is I can't make the logout work, using XMPPConnection.disconnect(), after this, when creating account or logging in another user, the error below is shown. Any one have used Smack API for this kind of scenario?

The app gets this error when tried to login the same or another user:

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)
1
I think that this could be related to SMACK-278Flow

1 Answers

3
votes

Try calling connect once more before you try and login the second time: once you call disconnect to log off the actual socket is closed. connect should re-open it.