powered by Jive Software

Reconnection failed using ConnectionListener

Dear all,

i have implements ConnectionListener inside of my ConnectionStateListener class, code as

public synchronized void reconnectionSuccessful() {
connection.login(Username,password,resource);

… my logic

}

When i disconnect the cable this method runs but below exception comes what can i do for reconnecting the logged user ?

conflict(409)
at org.jivesoftware.smack.SASLAuthentication.bindResourceAndEstablishSession(SASLA uthentication.java:434)
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 331)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)
at com.solverminds.chat.listener.ConnectionStateListener.reconnectionSuccessful(Co nnectionStateListener.java:122)
at org.jivesoftware.smack.PacketReader.notifyReconnection(PacketReader.java:235)
at org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:961)
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection. java:904)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1415)
at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:123)

Note:

i have using smack 3.1.0 API,

in first time connection, presence, roster and search are working fine when reconnecting conflict error will come.

Reply me thanks in advance.

Dear all,

 Till now I cannot able reconnect to Openfire server when connection brakes,

I am using smack API and JAVA swing client.

Any body please guide me.

Thanks in advance.

Hi,

I noticed the SASLAuthentication related error in your log.

Maybe you could try this before you attempt a login method call

SASLAuthentication.supportSASLMechanism(“PLAIN”, 0);

Cheers,

Earlence Fernandes

Hi earlenceferns,

Thank you for your suggestion,

I have tried your code, but same exception comes.

Any other way to achieve the reconnection, expecting sample code.

Hi,

Could you be a little specific about what exactly you are trying to achieve thru the reconnection?

cheers,

Earlence

Hi,

My Requirement:

  Want to show the Reconnection status to client.          

Result:

I want to disconnect and reconnect N- number of times…

For some time reconnection is working fine, some time conflict error occurs.

Note:

I have disconnect my Network cable for reconnection testing,

Some times I have use disable and enable the Network connection also.

When I disconnect the network cable below error will come:

javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Connection reset

    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1154)

    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.checkWrite(SSLSocketImpl.java:1166)

    at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:43)

    at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)

    at sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer(StreamEncoder.java:404)

    at sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:408)

    at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)

    at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)

    at java.io.BufferedWriter.flush(BufferedWriter.java:236)

    at org.jivesoftware.smack.PacketWriter.writePackets(PacketWriter.java:274)

    at org.jivesoftware.smack.PacketWriter.access$000(PacketWriter.java:40)

    at org.jivesoftware.smack.PacketWriter$1.run(PacketWriter.java:87)

Caused by: javax.net.ssl.SSLException: java.net.SocketException: Connection reset

    at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:166)

    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1476)

    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1443)

    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1 407)

    at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:86)

    at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)

    at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)

    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)

    at java.io.InputStreamReader.read(InputStreamReader.java:167)

    at java.io.BufferedReader.fill(BufferedReader.java:136)

    at java.io.BufferedReader.read1(BufferedReader.java:187)

    at java.io.BufferedReader.read(BufferedReader.java:261)

    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:368)

    at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)

    at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)

Caused by: java.net.SocketException: Connection reset

    at java.net.SocketInputStream.read(SocketInputStream.java:168)

    at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:284)

    at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:319)

    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:720)

    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:67 7)

    at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)

    ... 14 more

java.net.SocketException: Connection reset

    at java.net.SocketInputStream.read(SocketInputStream.java:168)

    at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:284)

    at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:319)

    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:720)

    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:67 7)

    at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)

    at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)

    at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)

    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)

    at java.io.InputStreamReader.read(InputStreamReader.java:167)

    at java.io.BufferedReader.fill(BufferedReader.java:136)

    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:368)

    at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)

    at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)

After reconnect the network cable below err will come:

conflict(409)

    at org.jivesoftware.smack.SASLAuthentication.bindResourceAndEstablishSession(SASLA uthentication.java:434)

    at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 331)

    at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)

    at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1426)

    at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:123)

Hi,

From your mail this is what i understand.

You want to connect and disconnect, then again reconnect to the XMPP server.

If this is true, why don’t you use the disconnect() method.

If u want to simulate a network failure, then u must handle exceptions from Java code and not Smack API

Hope this helps,

Cheers,

Earlence