AnsweredAssumed Answered

Smack sends some data twice after reconnection when Stream Management is enabled

Question asked by Igor Khomenko on Dec 2, 2015
Latest reply on Dec 8, 2015 by Flow

Hi there,


I have a simple Android demo app where I enabled Stream Management

 

connection.setUseStreamManagement(true);

 

and also handle WiFi reconnection events via ConnectionListener

 

I noticed one strange thing when I switch OFF and then ON WiFi on my Android phone.
My app is reconnecting back to the server and in logs I see the following

 

12-02 15:05:41.411 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='chat.quickblox.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>

12-02 15:05:41.544 31469-6612/com.igor.smackdemo D/SMACK: RECV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='chat.quickblox.com' id='ff35b34b-08dd-4a7c-9c18-adde7f014052' version='1.0' xml:lang='en'>

12-02 15:05:41.685 31469-6612/com.igor.smackdemo D/SMACK: RECV (0): <stream:features><sm xmlns="urn:xmpp:sm:3"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism >ANONYMOUS</mechanism></mechanisms><ver xmlns="urn:xmpp:features:rosterver"/><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression></stream:features>

12-02 15:05:41.692 31469-6058/com.igor.smackdemo I/System.out: LOG > connected

12-02 15:05:41.692 31469-6058/com.igor.smackdemo D/SMACK: XMPPConnection connected (0)

12-02 15:05:41.692 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>ADUxNzkyMTgtOTIAaWdvcnF1aWNrYmxveDcxMQ==</auth>

12-02 15:05:41.825 31469-6612/com.igor.smackdemo D/SMACK: RECV (0): <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>

12-02 15:05:41.825 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='chat.quickblox.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' id='ff35b34b-08dd-4a7c-9c18-adde7f014052' xml:lang='en'>

12-02 15:05:41.966 31469-6612/com.igor.smackdemo D/SMACK: RECV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='chat.quickblox.com' id='ff35b34b-08dd-4a7c-9c18-adde7f014052' version='1.0' xml:lang='en'>

12-02 15:05:42.138 31469-6612/com.igor.smackdemo D/SMACK: RECV (0): <stream:features><sm xmlns="urn:xmpp:sm:3"/><mobile xmlns="http://tigase.org/protocol/mobile#v3"/><ver xmlns="urn:xmpp:features:rosterver"/><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></stream:features>

12-02 15:05:42.138 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <iq id='UCh61-25' type='set'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>myresource</resource></bind> </iq>

12-02 15:05:42.278 31469-6612/com.igor.smackdemo D/SMACK: RECV (0): <iq to="5179218-92@chat.quickblox.com/myresource" id="UCh61-25" xmlns="jabber:client" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>5179218-92@chat.quickblox.com/myresource</jid></bind></iq>

12-02 15:05:42.286 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <iq id='UCh61-27' type='set'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>

12-02 15:05:42.427 31469-6612/com.igor.smackdemo D/SMACK: RECV (0): <iq to="5179218-92@chat.quickblox.com/myresource" id="UCh61-27" xmlns="jabber:client" type="result"/>

12-02 15:05:42.427 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <enable xmlns='urn:xmpp:sm:3'/>

12-02 15:05:42.567 31469-6612/com.igor.smackdemo D/SMACK: RECV (0): <enabled xmlns='urn:xmpp:sm:3' />

12-02 15:05:42.567 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <iq id='UCh61-14' type='set'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>

12-02 15:05:42.567 31469-6058/com.igor.smackdemo D/SMACK: User logged (0): 5179218-92@chat.quickblox.com:5222/myresource

12-02 15:05:42.567 31469-6058/com.igor.smackdemo I/System.out: LOG > authenticated

12-02 15:05:42.567 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <iq id='UCh61-16' type='get'><query xmlns='jabber:iq:roster'></query></iq>

12-02 15:05:42.567 31469-6058/com.igor.smackdemo D/SMACK: XMPPConnection authenticated (0)

12-02 15:05:42.567 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <r xmlns='urn:xmpp:sm:3'/>

12-02 15:05:42.575 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <presence id='UCh61-17'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='NfJ3flI83zSdUDzCEICtbypursw='/></presence>

12-02 15:05:42.575 31469-6058/com.igor.smackdemo I/System.out: LOG > reconnectionSuccessful

12-02 15:05:42.575 31469-6058/com.igor.smackdemo D/SMACK: XMPPConnection reconnected (0)

12-02 15:05:42.575 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <iq id='UCh61-25' type='set'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>myresource</resource></bind> </iq>

12-02 15:05:42.575 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <iq id='UCh61-27' type='set'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>

12-02 15:05:42.575 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <iq id='UCh61-29' type='get'><query xmlns='jabber:iq:roster'></query></iq>

12-02 15:05:42.583 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <presence id='UCh61-30'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='NfJ3flI83zSdUDzCEICtbypursw='/></presence>

12-02 15:05:42.583 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <r xmlns='urn:xmpp:sm:3'/>

12-02 15:05:42.716 31469-6612/com.igor.smackdemo D/SMACK: RECV (0): <a xmlns='urn:xmpp:sm:3' h='2'/>

12-02 15:05:42.724 31469-6612/com.igor.smackdemo D/SMACK: RECV (0): <a xmlns='urn:xmpp:sm:3' h='7'/><iq to="5179218-92@chat.quickblox.com/myresource" id="UCh61-14" xmlns="jabber:client" type="result"/><r xmlns='urn:xmpp:sm:3' /><iq to="5179218-92@chat.quickblox.com/myresource" id="UCh61-16" xmlns="jabber:client" type="result"><query xmlns="jabber:iq:roster"><item subscription="from" name="5179221-92" jid="5179221-92@chat.quickblox.com"/></query></iq><r xmlns='urn:xmpp:sm:3' /><iq to="5179218-92@chat.quickblox.com/myresource" id="UCh61-25" xmlns="jabber:client" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>5179218-92@chat.quickblox.com/myresource</jid></bind></iq><r xmlns='urn:xmpp:sm:3' /><iq to="5179218-92@chat.quickblox.com/myresource" id="UCh61-29" xmlns="jabber:client" type="result"><query xmlns="jabber:iq:roster"><item subscription="from" name="5179221-92" jid="5179221-92@chat.quickblox.com"/></query></iq><r xmlns='urn:xmpp:sm:3' /><iq to="5179218-92@chat.quickblox.com/myresource" id="UCh61-27" xmlns="jabber:client" type="result"/><r xmlns='urn:xmpp:sm:3' /><presence xmlns="jabber:client" from="5179218-92@chat.quickblox.com/myresource" to="5179218-92@chat.quickblox.com" id="UCh61-17"><c xmlns="http://jabber.org/protocol/caps" node="http://www.igniterealtime.org/projects/smack" hash="sha-1" ver="NfJ3flI83zSdUDzCEICtbypursw="/></presence><r xmlns='urn:xmpp:sm:3' /><presence xmlns="jabber:client" from="5179218-

12-02 15:05:42.724 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <a xmlns='urn:xmpp:sm:3' h='1'/>

12-02 15:05:42.731 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <a xmlns='urn:xmpp:sm:3' h='2'/>

12-02 15:05:42.731 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <a xmlns='urn:xmpp:sm:3' h='3'/>

12-02 15:05:42.739 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <a xmlns='urn:xmpp:sm:3' h='4'/>

12-02 15:05:42.739 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <a xmlns='urn:xmpp:sm:3' h='5'/>

12-02 15:05:42.755 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <a xmlns='urn:xmpp:sm:3' h='6'/>

12-02 15:05:42.864 31469-6612/com.igor.smackdemo D/SMACK: RECV (0): 92@chat.quickblox.com/myresource" to="5179218-92@chat.quickblox.com" id="UCh61-30"><c xmlns="http://jabber.org/protocol/caps" node="http://www.igniterealtime.org/projects/smack" hash="sha-1" ver="NfJ3flI83zSdUDzCEICtbypursw="/></presence><r xmlns='urn:xmpp:sm:3' />

12-02 15:05:42.864 31469-6611/com.igor.smackdemo D/SMACK: SENT (0): <a xmlns='urn:xmpp:sm:3' h='7'/>

 

So you can see that Smack sends some auth data twice

 

Here is my simple Android app to test this scenario

https://github.com/soulfly/smack-codesample/tree/master/android/SmackDemo/app/sr c/main/java/com/igor/smackdemo

Outcomes