powered by Jive Software

Wrong/unexpected data in received IQ

I am working with smack on Android with an ejabberd server. My server sends a few custom IQ’s to the client and while sending they appear to be correct. On reception at the client, unexpected data is seen in the IQ:

From server:

<iq type='result'><parenttag xmlns='jabber:iq:myns'><childtag>Data</childtag></parenttag></iq>

At client:

(With no IQProvider registered, printed IQ from MyPacketListener.processPacket()) ->

(Printed from processPacket())
     07-03 02:22:57.435: W/(19027): IQ = <iq id="v8C9N-2" type="result">nullDatanull</iq>
     07-03 02:22:57.435: W/(19027): ChildXML = nullDatanull

(With IQProvider registered, output from MyIQProvider.parseIQ()):

07-03 02:30:10.497: W/(19725): Start tag parenttag
07-03 02:30:10.497: W/(19725): Start tag childtag
07-03 02:30:10.497: W/(19725): Start tag null
07-03 02:30:10.497: W/(19725): Start tag childtag
07-03 02:30:10.505: W/(19725): Start tag parenttag
07-03 02:30:10.505: W/(19725): Start tag iq

The code for printing is:

int eventType = parser.getEventType();
        while(eventType != XmlPullParser.END_DOCUMENT) {
            if(eventType == XmlPullParser.START_DOCUMENT) {
                ABGUtil.LogIt("Start document");
            } else if(eventType == XmlPullParser.START_TAG) {
                ABGUtil.LogIt("Start tag "+parser.getName());
            } else if(eventType == XmlPullParser.END_TAG) {
                ABGUtil.LogIt("End tag "+parser.getName());
            } else if(eventType == XmlPullParser.TEXT) {
                ABGUtil.LogIt("Text "+parser.getText());
            }             parser.next();
        }

After “Start tag iq”, it keeps printing it forever.

Can someone please help me debug this?

After “Start tag iq”, it keeps printing it forever.
Because your condition for the wile loop is wrong. END_DOCUMENT is only received when the XMPP stream is closed, that is when the connection is termianted.

You are finished parsing that stanza when END_TAG is encountered on the same depth as when you started parsing the stanza.

Thanks for your input. But the question of the change in data received remains. I switched on debugging and saw that initially correct IQ is received by Smack with all data intact. But when processPacket is called the form of the IQ mentioned in my question appears.

Which version are you using?

I am using aSmack 0.8.10

Switch to 4.0.1-SNAPSHOT. Make sure to read the “Smack 4.0 Readme and Upgrade Guide”!

Alright, will try it out.

The compilation issues mostly got resolved easily on upgrading, but it seems ConnectionConfiguration.setSASLAuthenticationEnabled, setTruststoreType, setTruststorePassword, setTruststorePath and setTruststoreType are no longer available. What is the alternative way to achieve these in the new API? Would it be preferable if I start a new thread for this?

Yes, please open a new Thread.

Hey,

I got 4.0.1-SNAPSHOT working, but I continue to get similar results as before. Any other suggestion that you could offer?

Thanks,

Abhishek

Any other suggestion that you could offer?
Not without a detailed problem description.

The problem description remains the same as the original question. I still keep receiving the unexpected data in the IQ

07-03 02:30:10.497: W/(19725): Start tag parenttag 07-03 02:30:10.497: W/(19725): Start tag childtag 07-03 02:30:10.497: W/(19725): Start tag **null** 07-03 02:30:10.497: W/(19725): Start tag childtag 07-03 02:30:10.505: W/(19725): Start tag parenttag 07-03 02:30:10.505: W/(19725): Start tag iq