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

Hi,

 

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>

 

Exception:

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: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 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.

 

Thanks

Vishnu

Outcomes