powered by Jive Software

Getting connection 'closed on error' when previous connection is replaced by a new one


We are using Smack 4.2.0 with stream management enable on the server side(Using Ejabbered). At the client side, sometimes i am receiving stream error conflict which states that my previous connection is replaced by a new connection by the server. The error stanza we are receiving is-

Receiving Stanza:

stream:errorReplaced by new connection</stream:error>


org.jivesoftware.smack.XMPPException$StreamErrorException: conflict You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions

stream:errorReplaced by new connection</stream:error>

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1046)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon nection.java:980)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:996)

at java.lang.Thread.run(Thread.java:818)

It is fine that server has replaced my connection with a new one, but the point is we are getting connection closed on error from smack even we are still connected to the XMPP server. Upon receiving connection closed on error, we are trying to reconnect to the server and during this process we are checking if connected to the XMPP server or not through smack’s isConnected method in AbstractXMPPConnection class and getting false.

The problem is when we are already connected to the server, smack throws : 1. Connection closed on error 2. Smack doesn’t tell us we are already connected to the server(getting isConnected false).

Could you please provide some reference regarding this issue.