AnsweredAssumed Answered

XEP-313 xmlns

Question asked by Brian on Aug 6, 2016
Latest reply on Sep 14, 2016 by Anno van Vliet

I am new to XMPP, using Smack on Android. I started to look into XEP-313 to pull message archives from Open Fire (v4.0.2) to Android client. Was very pleased to see the recent efforts to add this to Smack 4.2 beta, so I switched from v4.1.7 to v4.2 beta (smack-nightly-SNAPSHOT-4.3-2016-08-04), however I am unable to pull message archives from Open Fire (with Monitoring plugin 1.5.4). As you'll see in verbose details below I was able to get it partially working with code change. My question boils down to which namespace is correct: Smack and XEP-313 (mam:1), or Open Fire (mam:0)?

 

 

Using Smack DEBUG flag, I found that Smack's new MAM Manager code is using  xmlns='urn:xmpp:mam:1 e.g.

 

SENT (0): <iq from='test1@192.168.98.10/990004820495921' id='qh3U3-17' type='set'><query xmlns='urn:xmpp:mam:1' queryid='4189c0bc-ea5e-4364-9bbf-5167bfd37975'><x xmlns='jabber:x:data' type='submit'><field var='FORM_TYPE' type='hidden'><value>urn:xmpp:mam:1</value></field><field var='start'><value>2016-08-07T03:18:00.222+00:00</value></field></x></query></i q>

 

 

 

but Open Fire seems to be reporting supported feature of <feature var="urn:xmpp:mam:0"/> e.g.

 

RECV (0): <iq type="result" id="qh3U3-15" from="192.168.98.10" to="test1@192.168.98.10/990004820495921"><query xmlns="http://jabber.org/protocol/disco#info"><identity category="server" name="Openfire Server" type="im"/><identity category="pubsub" type="pep"/><feature var="http://jabber.org/protocol/pubsub#retrieve-default"/><feature var="http://jabber.org/protocol/pubsub#purge-nodes"/><feature var="vcard-temp"/><feature var="http://jabber.org/protocol/pubsub#subscribe"/><feature var="http://jabber.org/protocol/pubsub#subscription-options"/><feature var="http://jabber.org/protocol/pubsub#create-nodes"/><feature var="http://jabber.org/protocol/pubsub#outcast-affiliation"/><feature var="msgoffline"/><feature var="http://jabber.org/protocol/pubsub#get-pending"/><feature var="http://jabber.org/protocol/pubsub#multi-subscribe"/><feature var="http://jabber.org/protocol/pubsub#presence-notifications"/><feature var="urn:xmpp:ping"/><feature var="jabber:iq:register"/><feature var="http://jabber.org/protocol/pubsub#delete-nodes"/><feature var="http://jabber.org/protocol/pubsub#config-node"/><feature var="urn:xmpp:archive:manage"/><feature var="http://jabber.org/protocol/pubsub#retrieve-items"/><feature var="http://jabber.org/protocol/pubsub#auto-create"/><feature var="http://jabber.org/protocol/disco#items"/><feature var="http://jabber.org/protocol/pubsub#item-ids"/><feature var="http://jabber.org/protocol/pubsub#meta-data"/><feature var="urn:xmpp:mam:0"/><feature var="jabber:iq:roster"/><feature var="http://jabber.org/protocol/pubsub#instant-nodes"/><feature var="http://jabber.org/protocol/pubsub#modify-affiliations"/><feature var="http://jabber.org/protocol/pubsub#persistent-items"/><feature var="http://jabber.org/protocol/pubsub#create-and-configure"/><feature var="http://jabber.org/protocol/pubsub"/><feature var="http://jabber.org/protocol/pubsub#publisher-affiliation"/><feature var="http://jabber.org/protocol/pubsub#access-open"/><feature var="http://jabber.org/protocol/pubsub#retrieve-affiliations"/><feature var="jabber:iq:version"/><feature var="http://jabber.org/protocol/pubsub#retract-items"/><feature var="urn:xmpp:time"/><feature var="http://jabber.org/protocol/pubsub#manage-subscriptions"/><feature var="jabber:iq:privacy"/><feature var="jabber:iq:last"/><feature var="http://jabber.org/protocol/commands"/><feature var="http://jabber.org/protocol/offline"/><feature var="urn:xmpp:carbons:2"/><feature var="http://jabber.org/protocol/address"/><feature var="http://jabber.org/protocol/pubsub#publish"/><feature var="http://jabber.org/protocol/pubsub#collections"/><feature var="http://jabber.org/protocol/pubsub#retrieve-subscriptions"/><feature var="urn:xmpp:archive:auto"/><feature var="http://jabber.org/protocol/disco#info"/><feature var="jabber:iq:private"/><feature var="http://jabber.org/protocol/rsm"/></query></iq>

 

 

 

As a result the Smack MamManager.isSupportedByServer() is returning false, and an attempt to queryArchive() fails with an error 503 from Open Fire e.g.

 

<iq type="error" id="qh3U3-17" to="test1@192.168.98.10/990004820495921"><query xmlns="urn:xmpp:mam:1" queryid="4189c0bc-ea5e-4364-9bbf-5167bfd37975"><x xmlns="jabber:x:data" type="submit"><field var="FORM_TYPE" type="hidden"><value>urn:xmpp:mam:1</value></field><field var="start"><value>2016-08-07T03:18:00.222+00:00</value></field></x></query><er ror code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

 

 

 

For a quick test, I modified my local smack-experimental-4.2.0-beta3-SNAPSHOT.jar to use xmlns='urn:xmpp:mam:0' e.g.

 

<iq from='test1@192.168.98.10/990004820495921' id='3rXpQ-17' type='set'><query xmlns='urn:xmpp:mam:0' queryid='27c5254a-692a-4c51-b220-0a84297a38e8'><x xmlns='jabber:x:data' type='submit'><field var='FORM_TYPE' type='hidden'><value>urn:xmpp:mam:0</value></field><field var='start'><value>2016-08-07T02:33:01.041+00:00</value></field></x></query></i q>

 

 

With this change, I was able to get delayed/forwarded messages sent back from Open Fire to my Smack client, followed by the FIN message. However, minor side issue, during processing of these messages I get these errors as well..

 

 

E/xceptionLoggingCallback﹕ Smack message parsing exception. Content: '</body><thread>8c1ba7cf-e539-4fcb-b364-c6d346a877d9</thread><request xmlns='urn:xmpp:receipts'></request></message></forwarded></result></message>'

 

    java.lang.IllegalArgumentException: Namespace must not be null or empty

            at org.jivesoftware.smack.util.StringUtils.requireNotNullOrEmpty(StringUtils.java: 426)

            at org.jivesoftware.smack.packet.StandardExtensionElement.<init>(StandardExtension Element.java:69)

            at org.jivesoftware.smack.packet.StandardExtensionElement.<init>(StandardExtension Element.java:43)

            at org.jivesoftware.smack.packet.StandardExtensionElement$Builder.build(StandardEx tensionElement.java:218)

            at org.jivesoftware.smack.parsing.StandardExtensionElementProvider.parse(StandardE xtensionElementProvider.java:96)

 

 

 

AND

 

 

    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.queryArchiveWithStartDate(MamManage.java :178)

Outcomes