Smack reconnect, prevent throwing of exceptions


I know that Smack reconnects when the connection is dropped abruptly, for instance, due to a network fault. This is a nice feature. However, when it disconnects, it throws a series of exceptions, which I want to catch.

Is there any way I can avoid the exceptions be thrown or at least catch them?

I tried putting a try/catch for the connect/login statement but it does not help.

Below is the output I am talking about: Connection reset by peer: socket write error

    at Method)

    at Source)

    at Source)

    at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)

    at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)

    at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)

    at sun.nio.cs.StreamEncoder.flush(Unknown Source)

    at Source)

    at Source)

    at org.jivesoftware.smack.PacketWriter.writePackets(

    at org.jivesoftware.smack.PacketWriter.access$000(

    at org.jivesoftware.smack.PacketWriter$ Connection reset

    at Source)

    at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)

    at sun.nio.cs.StreamDecoder.implRead(Unknown Source)

    at Source)

    at Source)

    at Source)

    at Source)

    at org.xmlpull.mxp1.MXParser.fillBuf(

    at org.xmlpull.mxp1.MXParser.more(

    at org.xmlpull.mxp1.MXParser.parseProlog(

    at org.xmlpull.mxp1.MXParser.nextImpl(


    at org.jivesoftware.smack.PacketReader.parsePackets(

    at org.jivesoftware.smack.PacketReader.access$000(

     at org.jivesoftware.smack.PacketReader$