简体   繁体   中英

Android Smack Ejabberd multiple connection issue

Im delveloping chat app using Ejabbered & smack on android client, Everytime user enters app I'm sending my presence as available to server & everytime user leaves app I'm sending the presence as unavailable so i can receive the offline messages which are sent after that.. But Though I send presence packet when leaving app, I can still see the user Online when i check from different client. Looking at logcat I suspect multiple connections are alive:

Logged out:

---------------------------------
06-22 12:36:42.473 2985-3052/ask.around D/SMACK: SENT (0): <presence id='R0C81-14' type='unavailable'><priority>1</priority><show>away</show></presence><r xmlns='urn:xmpp:sm:3'/>
06-22 12:36:42.474 2985-3052/ask.around D/SMACK: SENT (0): <presence id='R0C81-15' type='unavailable'></presence>
06-22 12:36:42.475 2985-3052/ask.around D/SMACK: SENT (0): <a xmlns='urn:xmpp:sm:3' h='5'/>
06-22 12:36:42.486 2985-3052/ask.around D/SMACK: SENT (0): 
06-22 12:36:42.487 2985-3052/ask.around D/SMACK: SENT (0): </stream:stream>
06-22 12:36:42.616 2985-3053/ask.around D/SMACK: RECV (0): <a h='5' xmlns='urn:xmpp:sm:3'/>
06-22 12:36:42.692 2985-3053/ask.around D/SMACK: RECV (0): </stream:stream>
06-22 12:36:42.693 2985-3271/ask.around D/SMACK: XMPPConnection closed (XMPPTCPConnection[moulesh@ask-around-chat/48305568695274620153122] (0))

not logged out:

06-22 12:02:01.952 2586-3299/ask.around D/SMACK: SENT (2): <presence id='86IU1-48' type='unavailable'><priority>1</priority><show>away</show></presence><r xmlns='urn:xmpp:sm:3'/><presence id='86IU1-49' type='unavailable'></presence><a xmlns='urn:xmpp:sm:3' h='6'/>
06-22 12:02:01.952 2586-3299/ask.around D/SMACK: SENT (2): </stream:stream>
06-22 12:02:02.032 2586-3300/ask.around D/SMACK: RECV (2): <a h='5' xmlns='urn:xmpp:sm:3'/>
06-22 12:02:02.052 2586-3282/ask.around D/SMACK: RECV (1): <presence xml:lang='en' to='moulesh@ask-around-chat/104236288900606474493066' from='moulesh@ask-around-chat/105858598794378801093074' type='unavailable' id='86IU1-48'><priority>1</priority><show>away</show></presence><r xmlns='urn:xmpp:sm:3'/>
06-22 12:02:02.053 2586-3281/ask.around D/SMACK: SENT (1): <a xmlns='urn:xmpp:sm:3' h='7'/>
06-22 12:02:02.099 2586-3300/ask.around D/SMACK: RECV (2): </stream:stream>
06-22 12:02:02.100 2586-2938/ask.around D/SMACK: XMPPConnection closed (XMPPTCPConnection[moulesh@ask-around-chat/105858598794378801093074] (2))

what is the mistake I'm making, I noticed in logcat of successful logout the number is always zero, n in unsuccessful one its upto 2 so am i creating multiple connections?? or the Number is not the no of connections?? if it is issue with number of connections How do I create a single n only instance till my app is alive??

You can shout down old instance before making connection That's may be help you .

if(mXmpptcpConnection!=null){
        mXmpptcpConnection.instantShutdown();
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM