I am using the latest smack-experimental:4.2.0-beta3-SNAPSHOT
and my server (prosody 0.10, implementing the MAM module (Originally mam:0 namespace)), I edited it to fit in the new mam:1 namespace and some other tweaks..
And I of course also stripped the archive message to only the body (so I'm not sure if that has anything to the with the error).
Please [disregard the acknowledgement packet] - not marked in bold.
Here is my Code:
try {
MamManager.MamQueryResult mamQueryResult = mamManager.queryArchive(2);
} catch (XMPPException.XMPPErrorException e) {
e.printStackTrace();
} catch (SmackException.NotLoggedInException e) {
e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (SmackException.NoResponseException e) {
e.printStackTrace();
}
SMACK sent this (to the server) [relevant info in bold]:
D/SMACK: SENT (0):
<iq id='5leDW-18' type='set'>
<query xmlns='urn:xmpp:mam:1' queryid='f80c9e04-c6a7-464b-b9b8-3ee9caa27d87'>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>2</max>
</set>
</query>
</iq>
<r xmlns='urn:xmpp:sm:3'/>
SMACK received this (from the server):
D/SMACK: RECV (0):
<iq id='5leDW-18' type='result' to='admin@myServer.com/LG-D855@g3_global_com@LGE'/>
<message to='admin@myServer.com/LG-D855@g3_global_com@LGE'>
<result id='702878b8-2d93-4a51-adaa-2a49f20eb544' queryid='f80c9e04-c6a7-464b-b9b8-3ee9caa27d87' xmlns='urn:xmpp:mam:1'>
<forwarded xmlns='urn:xmpp:forward:0'><delay stamp='2016-10-04T02:07:40Z' xmlns='urn:xmpp:delay'/>
<message xmlns='jabber:client'><body>fdsdf</body></message>
</forwarded>
</result>
</message>
<message to='admin@myServer.com/LG-D855@g3_global_com@LGE'>
<result id='40f9cb2d-3bb2-493a-b89b-bb258f7deb38' queryid='f80c9e04-c6a7-464b-b9b8-3ee9caa27d87' xmlns='urn:xmpp:mam:1'>
<forwarded xmlns='urn:xmpp:forward:0'><delay stamp='2016-10-04T02:11:37Z' xmlns='urn:xmpp:delay'/>
<message xmlns='jabber:client'><body>stop</body></message>
</forwarded>
</result>
</message>
<r xmlns='urn:xmpp:sm:3'/>
<message to='admin@myServer.com/LG-D855@g3_global_com@LGE'>
<fin complete='true' queryid='f80c9e04-c6a7-464b-b9b8-3ee9caa27d87' xmlns='urn:xmpp:mam:1'>
<set xmlns='http://jabber.org/protocol/rsm'>
<first>702878b8-2d93-4a51-adaa-2a49f20eb544</first>
<count>9.8813129168249e-324</count>
<last>40f9cb2d-3bb2-493a-b89b-bb258f7deb38</last>
</set>
</fin>
</message>
<a h='5' xmlns='urn:xmpp:sm:3'/>
And then the error comes after (which force-closed my APP)
E/AndroidRuntime: FATAL EXCEPTION:main
java.lang.ClassCastException: org.jivesoftware.smack.packet.EmptyResultIQ cannot be cast to org.jivesoftware.smackx.mam.element.MamFinIQ
at org.jivesoftware.smackx.mam.MamManager.queryArchive(MamManager.java:396)
at org.jivesoftware.smackx.mam.MamManager.queryArchive(MamManager.java:232)
at org.jivesoftware.smackx.mam.MamManager.queryArchive(MamManager.java:109)
Looking at the error, I am having a feeling the first <iq/> packet received has something to do with it... so I went with the latest 0.5 revision which replaced the <fin/> parent element with <iq/> instead of <message/> :http://xmpp.org/extensions/diff/api/xep/0313/diff/0.3/vs/0.5#query-limit
So instead of the <iq/> result arriving first, it arrives last after all the messages have been completed:
SMACK Received (from server):
D/SMACK: RECV (0):
<message to='admin@myServer.com/LG-D855@g3_global_com@LGE'>
<result id='702878b8-2d93-4a51-adaa-2a49f20eb544' queryid='dafcab44-4064-4d11-9d12-4960d636bf3f' xmlns='urn:xmpp:mam:1'>
<forwarded xmlns='urn:xmpp:forward:0'><delay stamp='2016-10-04T02:07:40Z' xmlns='urn:xmpp:delay'/>
<message xmlns='jabber:client'><body>fdsdf</body></message>
</forwarded>
</result>
</message>
<r xmlns='urn:xmpp:sm:3'/>
<message to='admin@myServer.com/LG-D855@g3_global_com@LGE'>
<result id='40f9cb2d-3bb2-493a-b89b-bb258f7deb38' queryid='dafcab44-4064-4d11-9d12-4960d636bf3f' xmlns='urn:xmpp:mam:1'>
<forwarded xmlns='urn:xmpp:forward:0'><delay stamp='2016-10-04T02:11:37Z' xmlns='urn:xmpp:delay'/>
<message xmlns='jabber:client'><body>stop</body></message>
</forwarded>
</result>
</message>
<iq id='N58WO-18' type='result' to='admin@myServer.com/LG-D855@g3_global_com@LGE'>
<fin complete='true' queryid='dafcab44-4064-4d11-9d12-4960d636bf3f' xmlns='urn:xmpp:mam:1'>
<set xmlns='http://jabber.org/protocol/rsm'>
<first>702878b8-2d93-4a51-adaa-2a49f20eb544</first>
<count>9.8813129168249e-324</count>
<last>40f9cb2d-3bb2-493a-b89b-bb258f7deb38</last>
</set>
</fin>
</iq>
<a h='5' xmlns='urn:xmpp:sm:3'/>
But Connection closed immediately after the message (with Invalid Int at the count):
AbstractXMPPConnection: Connection XMPPTCPConnection[admin@myServer.com/LG-D855@g3_global_com@LGE] (0) closed with error
java.lang.NumberFormatException: Invalid int: "9.8813129168249e-324"
at java.lang.Integer.invalidInt(Integer.java:138)
at java.lang.Integer.parse(Integer.java:410)
at java.lang.Integer.parseInt(Integer.java:367)
at java.lang.Integer.parseInt(Integer.java:334)
at java.lang.Integer.valueOf(Integer.java:525)
at org.jivesoftware.smack.util.ParserUtils.getIntegerFromNextText(ParserUtils.java :153)
at org.jivesoftware.smackx.rsm.provider.RSMSetProvider.parse(RSMSetProvider.java:5 6)
at org.jivesoftware.smackx.rsm.provider.RSMSetProvider.parse(RSMSetProvider.java:2 7)
at org.jivesoftware.smack.provider.Provider.parse(Provider.java:31)
at org.jivesoftware.smackx.mam.provider.MamFinIQProvider.parse(MamFinIQProvider.ja va:48)
at org.jivesoftware.smackx.mam.provider.MamFinIQProvider.parse(MamFinIQProvider.ja va:34)
at org.jivesoftware.smack.provider.Provider.parse(Provider.java:31)
at org.jivesoftware.smack.util.PacketParserUtils.parseIQ(PacketParserUtils.java:63 1)
at org.jivesoftware.smack.util.PacketParserUtils.parseStanza(PacketParserUtils.jav a:151)
at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMP PConnection.java:981)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$500(XMPPTCPConnection.java: 146)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1005)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon nection.java:960)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:975)
at java.lang.Thread.run(Thread.java:818)
Is this because of the "index='?'" missing at the <first/> element or something else? Please Help..Thank you.