powered by Jive Software

XMPPTCPConnection - roster and send presence order change


We are upgrading to the new Smack library 4.0.2 (previously 3.4.1) and we have noticed in our application that we no longer have presence registered on start up. Presence updates work - but the inital load up does not work.

All the information is transfer on the login command. I did some digging.

v3.4.1 -> XMPPConnection -> login

The roster is loaded first from the server - once done the presence is sent out (and subsequently presence is sent back) - all good.

 if(roster == null)

    roster = new Roster(this);




      packetWriter.sendPacket(new Presence(org.jivesoftware.smack.packet.Presence.Type.available));

v4.0.2 -> XMPPTCPConnection -> login

The presence is sent first. Then later in the same method a call to this method executes the RosterReload () from a connectionListener added in the Roster Class method Roster.

    // Set presence to online.

    sendPacket(new Presence(Presence.Type.available));





The reason this is a problem is because in class Roster the PresencePacketListener checks the Presence update to ensure the users JID is loaded in the Roster. If it is not loaded (in this case because the Presence is received before the Roster) - then then listeners are not fired.

            // If the user is in the roster, fire an event.

            RosterEntry entry = entries.get(key);

            if (entry != null) {



Is this intentional? Should we be doing something different to ensure we read presence and not rely on this?

Sorry if this is obvious - it is my first post



Thanks for reporting SMACK-596

Until a snapshot/released version with the fix is available. Please set sendInitialPresence to false and make sure that you send the initial presence manually after retrieving the Roster.



Please could you make a similar change to XMPPBOSHConnection?

My next job is to try and get Smack and OpenFire connected using BOSH




1 Like