Roster problems--revisited

Hey everyone!

So I was having trouble with Roster’'s and I found a related thread:

http://www.jivesoftware.org/community/thread.jspa?threadID=12929

The issue is with the way the Roster stores JID’‘s. Here’'s a snippet of a unit test to see what I mean:

Roster roster = this.xmppConnection.getRoster();

assertNotNull(roster);

String jidWithoutResource = “junit@” + this.xmppConnection.getHost();

roster.createEntry(jidWithoutResource, jidWithoutResource, null);

// entry will NOT be null

RosterEntry entry = roster.getEntry(jidWithoutResource);

assertNotNull(entry);

roster.removeEntry(entry);

/code

Do you think this will succeed? It actually won’'t. It will fail at the last line on the call to removeEntry (specifically, XMPPException: No response from the server.).

What about this?

Roster roster = this.xmppConnection.getRoster();

assertNotNull(roster);

String jidWithResource = this.xmppConnection.getUser();

roster.createEntry(jidWithResource, jidWithResource, null);

// entry will be null

RosterEntry entry = roster.getEntry(jidWithResource);

assertNotNull(entry);

roster.removeEntry(entry);

/code

This doesn’‘t work either, actually. It’'ll fail on the assertNotNull.

In the thread I mentioned before, the issue of whether the Roster should contain/accept full JIDs (including resource) came up. According to RFC3921, section 7.1:

“The “key” or unique identifier for each roster item is a JID, encapsulated in the ‘‘jid’’ attribute of the element (which is REQUIRED). The value of the ‘‘jid’’ attribute SHOULD be of the form user@domain if the item is associated with another (human) instant messaging user.”

The JID without a resource makes sense if you’'re doing (human) IMing, but our XMPP network uses them extensively.

Can someone please explain this to me, and how I should go about using the Roster properly? Thanks!

Hey everyone!

So I was having trouble with Roster’'s and I found a

related thread:

http://www.jivesoftware.org/community/thread.jspa?thre

adID=12929

The issue is with the way the Roster stores JID’'s.

Here’'s a snippet of a unit test to see what I mean:

Roster roster = this.xmppConnection.getRoster();

assertNotNull(roster);

String jidWithoutResource = “junit@” +

  • this.xmppConnection.getHost();

roster.createEntry(jidWithoutResource,

e, jidWithoutResource, null);

// entry will NOT be null

RosterEntry entry =

= roster.getEntry(jidWithoutResource);

assertNotNull(entry);

roster.removeEntry(entry);

/code

Do you think this will succeed? It actually won’'t.

It will fail at the last line on the call to

removeEntry (specifically, XMPPException: No

response from the server.).

Try increasing your packet timeout. and also can you post the raw sent and received packets from the debugger? I imagine that your response is being returned but for whatever reason smack is not seeing it, hence you get the error.

Thanks for the response!

Anything above a 300ms timeout had no effect on anything. I’‘m on LAN and I’'m using Jive Messenger as my XMPP server.

So, there’‘s two cases to dissect here: JIDs with and JIDs without a resource. I’'ll focus on the JIDs with a resource first, as I think this is more valuable:

String jidWithResource = this.xmppConnection.getUser();

roster.createEntry(jidWithResource, jidWithResource, null);

// entry will be NOT null because I get rid of the resource

RosterEntry entry = roster.getEntry(createJIDWithoutResource(jidWithResource));

assertNotNull(entry);

roster.removeEntry(entry);

/code

So I figured out the null return from getEntry(). The entries inside the Roster don’‘t store the resource as part of the user’‘s name, so a proper match will never ever happen because I always the resource in there. So created a little function to remove the resource from the JID string, and that’'s what createJIDWithoutResource() does.

I’‘m not exactly sure which XML packets I should post, so I’'ll post almost all of it.

Sent packets:

/code

I hope that’‘s not too much. Here’'s the received packets:

/code

Actually, looking at this, it seems my IQ SET request to remove the entry has packet ID A9jF7-7 while the server’'s response has packet ID 492-5156. Am I reading this correctly?

That would make sense because the packet collector filters on that packet ID in Roster.removeEntry().

FYI for everyone, here’‘s the part of the XMPP spec that talks about what’'s supposed to happen between the server and the client:

http://www.xmpp.org/specs/rfc3921.html#int-remove

Thanks for your help!

Yea, i’‘ve been having that problem periodically as well. I just ended up sending the roster packet myself and I have a roster packet listener that basicly listens for and parses updates. So, in the end I basicly rewrote smack’'s roster functionality. Otherwise it was too difficult to see what was being updated when and where, and when the server returned different packets like is the case that you are experiening the roster was becoming out of sync.

Alex

Actually, there is no “result” response in your listing, which would correcpond to request A9jF7-7. Packet with id 492-5156 has type ‘‘set’’, not ‘‘result’’. Accoding to document you’'ve mentioned, you should have got a packet like

,

but there is no such packet in the response you’'ve got.

Actually, there is no “result” response in your

listing, which would correcpond to request A9jF7-7.

Packet with id 492-5156 has type ‘‘set’’, not ‘‘result’’.

Accoding to document you’'ve mentioned, you should

have got a packet like

<iq type=“result” id=“A9jF7-7”

to="junit@example.com/junit"/>,

but there is no such packet in the response you’'ve

got.

Hmm… so what does that mean? There’'s a bug with the XMPP server (Jive Messenger)?