powered by Jive Software

Adding new roster entry does not always trigger RosterListener event

I’m using Smack 3.2.2 and OpenFire 3.7.1.

Normally when we call Roster#createEntry that generates a RosterListener event as expected and we add new user that user to our app’s roster. However that does not always happen. It’s random but often there is no RosterListener event fired. This seems to happen a bit more often if the new contact has no groups but I it happens when a group is specified and when it’s not specified.

Is this a known issue? Why does this happen? How can I work around this?



Upon further investigation it seem our code was not propertly handling the initial roster list when the connection was first made (no idea why we wern’t). This omission caused the RosterPacketListener to not recognize new roster entries because presumably it already had those entries…so they just fell out.

However this all hignes on getting the original roster list correctly. We first make a call to roster.reload() which I would think would trigger building the list but that often does not so we have another call to roster.getEntries() and then we send those to RosterListener#entriesUpdated() which does work almost all the time. However I have found one time in testing that even that did not work…no results were returned.

So I’m thinking there must be some timing issue here. What is the guarenteed way of getting the server’s roster list when the connection starts?

If i remember correctly the smack itself will just perform get initial roster and carrys on the process.

There is a chance that the initial roster packet is not recieved yet and your app just perform the login and roster management to fast.

I was used to use a dirty thread sleep for approx 5 secs, which is not a proper way.

Currently the fix i made is create a custom .Net like autoresetevent which will pause the app login process before carrys on if and only if it was triggered from the roster packet listener. So that i could assure the existant of initial roster.

Hopes that might help. I could provide some snippets if needed.