When joining a MUC with a user who is using Google Talk, PacketParserUtils will throw a XmlPullParserException. Here is a log of the message which causes the exception, and the traceback.
10:18:43 AM XMPPConnection closed due to an exception (1910846198)
org.xmlpull.v1.XmlPullParserException: Non-empty element tag not followed by text, while Mixed Content (XML 3.2.2) is disallowed
at org.jivesoftware.smack.util.PacketParserUtils.parseElementText(PacketParserUtil s.java:193)
at org.jivesoftware.smack.util.PacketParserUtils.parseMessage(PacketParserUtils.ja va:130)
at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:156)
at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:47)
at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:81)
It looks like the issue is caused by Google including XML inside the tag, which the parser does not allow. It may be that Google is violating the spec here, but even if they are, I’m not sure it should cause an exception to be thrown (which causes a disconnect/reconnect of the connection).
Is there some way to catch/handle this exception or message type? I’m using smack 4.0.4, with a XMPPTCPConnection, using core, extensions, and tcp.
This has allowed me to catch the exception, however it seems to be getting stuck in some sort of loop while parsing the stanza.
When a gtalk user joins a MUC, my callback is being called as expected. It gets a UnparsablePacket with this as the content:
I simply take no action and throw no exception, intending for the parser to ignore the packet. However, my callback is them immediately invoked again, with content of “” and exception of “java.lang.IndexOutOfBoundsException: only START_TAG can have attributes END_TAG seen …“false” xmlns:arc=“http://jabber.org/protocol/archive”/>… @1:3642”.
This repeats in an infinite loop - the callback keeps getting called with a new UnparsablePacket of “” as soon as it returns.
How should I be recovering inside of handleUnparsablePacket to allow it to ignore the packet and continue on?
Thanks. Can you direct me to where snapshots of 4.0.5 are located? I don’t see a branch on github, and the nightly builds page only has 4.1.0 and 4.0.0 builds:Ignite Realtime: Smack API Nightly Builds
Got it. I’ve updated my smack-core, smack-extensions, and smack-tcp to 4.0.5-SNAPSHOT. The JAR Ivy has is smack-core-4.0.5-SNAPSHOT.jar dated 11/21 2:57 PM CST.
I’m still seeing the same infinite loop, with my callback being called continually with a packet containing “”.
Here is the exception and stacktrace the first time it is called (this is the call that I’m expecting, due to Google’s violation of the spec):
org.xmlpull.v1.XmlPullParserException: Non-empty element tag not followed by text, while Mixed Content (XML 3.2.2) is disallowed
at org.jivesoftware.smack.util.PacketParserUtils.parseElementText(PacketParserUtil s.java:193) ~[smack-core-4.0.5-SNAPSHOT.jar:4.0.5-SNAPSHOT]
at org.jivesoftware.smack.util.PacketParserUtils.parseMessage(PacketParserUtils.ja va:130) ~[smack-core-4.0.5-SNAPSHOT.jar:4.0.5-SNAPSHOT]
at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:156) [smack-tcp-4.0.5-SNAPSHOT.jar:4.0.5-SNAPSHOT]
at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:47) [smack-tcp-4.0.5-SNAPSHOT.jar:4.0.5-SNAPSHOT]
at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:81) [smack-tcp-4.0.5-SNAPSHOT.jar:4.0.5-SNAPSHOT]
Here is the exception and stacktrace when it is called after that, in the infinite loop (the content is “”):
java.lang.IndexOutOfBoundsException: only START_TAG can have attributes END_TAG seen …“false” xmlns:arc=“http://jabber.org/protocol/archive”/>… @1:3656
at org.xmlpull.mxp1.MXParser.getAttributeValue(MXParser.java:927) ~[xpp3-1.1.4c.jar:na]
at org.jivesoftware.smack.util.PacketParserUtils.parseMessage(PacketParserUtils.ja va:85) ~[smack-core-4.0.5-SNAPSHOT.jar:4.0.5-SNAPSHOT]
at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:156) [smack-tcp-4.0.5-SNAPSHOT.jar:4.0.5-SNAPSHOT]
at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:47) [smack-tcp-4.0.5-SNAPSHOT.jar:4.0.5-SNAPSHOT]
at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:81) [smack-tcp-4.0.5-SNAPSHOT.jar:4.0.5-SNAPSHOT]