AnsweredAssumed Answered

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

Question asked by Vishnu Prajapati on Jun 23, 2017



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:error><conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xml:lang='en'>Replaced by new connection</text></stream:error>



org.jivesoftware.smack.XMPPException$StreamErrorException: conflict You can read more about the meaning of this stream error at

<stream:error><conflict xmlns='urn:ietf:params:xml:ns:@xmpp-streams'/><text xml:lang='en'>Replaced by new connection</text></stream:error>

                                                              at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC

                                                              at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon

                                                              at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$



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.