org.xmlpull.v1.XmlPullParserException:

Hello everyone,

I have a problem with org.xmlpull.v1.XmlPullParserException.

When receiving a lot of offline messages(with custom offline extension) at the same time, in one out of the ten cases Smack fails to parse packets as they are “corrupted” and i don’t know why.

here is the stacktrace:

aug 25, 2015 11:17:18 AM org.jivesoftware.smack.AbstractXMPPConnection callConnectionClosedOnErrorListener

WARNING: Connection closed with error

org.xmlpull.v1.XmlPullParserException: end tag name must match start tag name from line 1 (position: END_TAG seen …… @1:19741)

at org.xmlpull.mxp1.MXParser.parseEndTag(MXParser.java:1689)

at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1172)

at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)

at org.jivesoftware.smack.util.PacketParserUtils.parseContentDepthWithRoundtrip(Pa cketParserUtils.java:510)

at org.jivesoftware.smack.util.PacketParserUtils.parseContentDepth(PacketParserUti ls.java:429)

at org.jivesoftware.smack.util.PacketParserUtils.parseContentDepth(PacketParserUti ls.java:401)

at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMP PConnection.java:955)

at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$400(XMPPTCPConnection.java: 139)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:980)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPCon nection.java:935)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:950)

at java.lang.Thread.run(Thread.java:745)

i found similar threads “Random” XmlPullParserException

Frequent XmlPullParserException in Smack 3.2

which unfortunately were not solved, in the last one user Flow proposed using callback and to get unparseable stanza, i registered it, however unfortunately it didn’t trigger.

Any ideas on this issue?

Thanks in advance.

Why don’t you show us an example of such an message with an custom offline extension and the code for the provider parsing this custom extension?

Here is our custom provider with the extension itself

public class OfflineMessageReceiveExtension implements ExtensionElement {

** public static final String ELEMENT = “delay”;**

** public static final String NAMESPACE = “urn:xmpp:auth”;**

** private String stamp;**

** public OfflineMessageReceiveExtension(String stamp) {**

** this.stamp = stamp;**

** }**

** public String getStamp() {**

** return stamp;**

** }**

** @Override
public String getElementName() {**

** return ELEMENT;**

** }**

** @Override
public String getNamespace() {**

** return NAMESPACE;**

** }**

** @Override
public CharSequence toXML() {**

** return “<” + ELEMENT + " xmlns=’" + NAMESPACE + “’ stamp=’” + stamp + “’/>”;**

** }**

** public static class Provider extends ExtensionElementProvider {**

** @Override
public Element parse(XmlPullParser xmlPullParser, int i) throws XmlPullParserException, IOException, SmackException {**

** return new OfflineMessageReceiveExtension(xmlPullParser.getAttributeValue(1));**

** }**

** }**

}

Here is the screenshot of smack debug window, as you can see message tag gets corrupted and only age is seen, and delay xml element also got corrupted. Also id attribute starts withuot apostrof ".

Here message tag again got corrupted

parseerror2.png

May we are doing something wrong? may be our custome provider is not correct? But as i said this happens approximately one out of ten times.

That does look like the stanzas arrive corrupted at the client.

i have looked using packet sniffer, at the recieved xmpp packets length with error and without, they were the same. And at the server side, as far as i know before sending packets, they are validated. Might it be that parser fails to parse because of the stress?

Could also be cause by a corrupt/not agreed on deflate dictionary. Do you use compression? If so, try to disable it.