AnsweredAssumed Answered

Packet Interceptor doesn't get Presence

Question asked by Barabas on Apr 30, 2015
Latest reply on Apr 30, 2015 by Barabas

Hi, I apologize for posting another thread, but it seems that I have another roadblock with Smack/XMPP. I am trying to create a friends/roster addition request right now.

I've set the Subscriptionmode to manual in order for the receiver to process requests. I then created a packet listener to receive packets pertaining to Presence. However, sent packets are received, but the sender sending the presence receives said packet. According to the debug, the presence stanza is being received by the recipient but not found in the PacketInterceptor.


Here's my code:


Roster roster = Roster.getInstanceFor(connection);
        connection.addPacketInterceptor(new StanzaListener() {
            public void processPacket(Stanza packet) throws SmackException.NotConnectedException {
                Log.e(TAG, "something called");
                Presence presence = (Presence) packet;
                if(((Presence) packet).getType() == Presence.Type.subscribe) {
                    Log.e(TAG, "Packet type subscribe");
                if(presence.getType() == Presence.Type.subscribe) {
                    Log.e(TAG, "Subscribe type from: " + presence.getFrom());
                if(presence.getType() == Presence.Type.subscribed) {
                    Log.e(TAG, "SUBSCRIBED type from: " + presence.getFrom());
        }, new StanzaTypeFilter(Presence.class));


Here's how I send the presence:

String myJID = connectionManager.getConnection().getUser();

        Presence response = new Presence(Presence.Type.subscribe);

        response.setTo(eventListAdapter.getItem(position).getSender() + "/Smack");

        try {
        } catch (SmackException.NotConnectedException e) {


Here is the DEBUG line the receiver receives:

<?xml version="1.0" encoding="UTF-8"?>
<presence from="" to="" xml:lang="en" id="eTer5-50" type="subscribe">
   <c xmlns="" hash="sha-1" node="" ver="NfJ3flI83zSdUDzCEICtbypursw=" />
So it seems that my client is receiving the presence but the packet listener isn't processing it for some reason. However, the sending client recognizes it fine