Android / XMPP: packet listener ignores/drops UNAVAILABLE presences

Hi

I’m trying to establish a simple xmpp group chat on Android using the asmack xmpp library. And basically everything is working, except: UNAVAILABLE presences, i.e., when a user leaves a chat room, seem to be ignored in most cases. The strange part is, sometimes it works, but very rarely.

Presences from users entering the group chat are fine, so are messages. Both my local Openfire server as well as a xmpp client (Instantbird) tell me that there is a UNAVAILABLE presence when user leaves. Only my stuff has troubles.

Here’s the relevant snippet of my code.

this.listener = new PacketListener() {

@Override

public void processPacket(Packet packet) {

if (packet instanceof Presence)

handlePresence((Presence)packet);

else if (packet instanceof Message)

handleMessage((Message)packet);

}

};

this.xmppClient.getXMPPConnection().addPacketListener(

this.listener,

new OrFilter(new PacketTypeFilter(Presence.class),

new PacketTypeFilter(Message.class)));

I appriciate any hint in that! Thanks!

You could try to start your android app with eclipse in debug mode while setting a breakpoint at the PacketListener processPacket() call. You need to attach the (a)smack source for best debuging resulsts.

Flow

Hi Flow,

Thanks for your reply! I work with Eclipse and use the LogCat concsole to display System.out.println(). I just put one as the first command of the processPacket method, before the if clause. In case of AVAILABLE presences (newly joined users) and messages I get the output. But not when a user leaves the chat.

And I cannot reproduce the rare occasions when it works. This is actually the part that really bothers me.

Thanks and best regards,

Christian

Try to work with breakpoints and not with println(). You could also set a breakpoint in Smacks PacketReader class and trace the way of the unavailable packet through Smack. Start debuging with the breakpoint disabled and enable it just before you send the unavailable packet.