powered by Jive Software

Received IQ dropping elements between RCV and processPacket

I’m attempting to receive a custom IQ result packet on Smack 4.1.0-alpha1-SNAPSHOT, and some of the XML elements are being dropped between the reception of the packet and the delivery to my listener.

I’ve set SmackConfiguration.DEBUG_ENABLED = true, and I receive the following stanza: (Cleaned up a little to make readable)

11:11:59 PM RCV  (1631684231): <iq type="result" id="j6p8N-33" from="lighthouse.seattle1.adspore.com"
     <account xmlns="http://adspore.com/v1/lighthouse">

However, by the time it reaches my PacketFilter/PacketListener, it looks like this…

<iq id='j6p8N-33' to='bot_ijyffc@seattle1.adspore.com/Smack'           from='lighthouse.seattle1.adspore.com' type='result'>
          .... missing bits....

I’ve configured a PacketFilter to accept everything, and add the listener for it just before sending the outgoing IQ like this:

public void sendAccount() {
        AccountIQ accountIQ = new AccountIQ(getUsername(), "foo@foo.bar", true, 0L);
        LOG.info("Sending AccountInfo:" + accountIQ.toString());
        try {
            mConnection.addPacketListener(this, new AcceptEverythingPacketFilter());
        } catch (SmackException.NotConnectedException e) {
            LOG.error("Caught exception", e);

Here is the PacketFilter and handler:

    public void processPacket(Packet packet) throws SmackException.NotConnectedException {
        if (packet instanceof IQ) {
            LOG.info("Received IQ:" + packet.toXML());
    }     private class AcceptEverythingPacketFilter implements PacketFilter {
        public boolean accept(Packet packet) {
            LOG.info("Checking packet:" + packet.toString());
            return true;

Thanks for any help, I’m not able to determine where the characters are getting lost.

Nice report, but you missed the most important part. You didn’t tell us about the Provider implementation that is reponsible for parsing the custom IQ. Or, if you use the “parseWithIntrospection” feature of Smack, the AccountIQ class and how you’ve added it to the ProviderManger.

Thanks for the correction! You were 100% correct that the Provider class and ProviderManager were key to the problem, and I’m also a little embarrassed that I missed that. I was trying to avoid any complications on a quick little app, and simply wanted to catch and parse the incoming steam in a single callback.

The javadocs are not 100% clear about the purpose of the “Provider” concept, and even the quickstart docs seem to bypass discussion about their intended purpose and importance. Please correct my interpretation if it’s incorrect.

Using terms that I recognize better, The ProviderManager is really a “Stream to packet Factory”, with each implementation of ‘xxProvider’ being the ‘factory method’ on an incoming sequence of characters. The parsing of the XML to Packets has been decoupled from the actual handling of the packets, which I assume now is handled on a separate thread to keep the stream handling responsive. What I was attempting to do was parse and handle in a single operation.

Thanks again.