AnsweredAssumed Answered

Unavailable presence send by Smack library

Question asked by Neeraj on Apr 19, 2016
Latest reply on May 22, 2016 by Flow

I am using smack library for implementing xmpp based chat on my android device. Consider a scenario when user's internet connection is gone and user is still typing some offline messages on the device.

Consider when the internet connection is restored again, there is a queue of following xml stanzas:

chatstate : composing

chatstate : active

message: text

chatstate : paused

Now after the connection with ejabberd is completed along with the required authentication check, Smack will send all the queued stanzas to the server.

Following are some of the stanzas received on the server side:

 

<r xmlns='urn:xmpp:sm:3'/><presence id='TO9VT-163' type='unavailable'></presence><r xmlns='urn:xmpp:sm:3'/><presence id='TO9VT-164' type='unavailable'></presence><r xmlns='urn:xmpp:sm:3'/><presence id='TO9VT-165' type='unavailable'></presence><presence id='TO9VT-197'><status>away</status><show>away</show><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='os2Kusj3WEOivn5n4iFr/ZEO8ls='/></presence><r xmlns='urn:xmpp:sm:3'/><presence id='TO9VT-166' type='unavailable'></presence><r xmlns='urn:xmpp:sm:3'/><r xmlns='urn:xmpp:sm:3'/><a xmlns='urn:xmpp:sm:3' h='84'/><r xmlns='urn:xmpp:sm:3'/>

 

Xml received by server contains a lot of presence type=unavailable stanzas. This results in client presence state toggling between online and offline and sometimes finally settling as offline.

This leads to a misleading state when actually client has the chat window open (is online), but on server client is registered as offline, so the messages aren't received by the user and stored on offline storage of server.

Can anyone explain the above behaviour of smack library.

Outcomes