powered by Jive Software

Parsing exception when querying MAM archive - MamManager.queryArchive failed with "Not a valid combination of localpart, domainpart and resource"

Smack version 4.3.4
Android 9
MongooseIM 3.3.0

Smack doesn’t seem to like the responses from MongooseIM when calling MamManager.queryArchive.

Please help.

Many thanks in advance.


Unparseable Stanza: <message xmlns='jabber:client' from='muc_light_1@example.com/user2@example.com' to='' id='e81d40f4-c86d-474f-a9e7-e06cd8cb3857' type='groupchat'><body>46</body><item-type type='1' mime-type=''/><markable/></message></forwarded></result></message> (Not a valid combination of localpart, domainpart and resource)


MamManager mamManager = MamManager.getInstanceFor(connection, chatRoomID);
MamManager.MamQueryArgs.Builder builder = MamManager.MamQueryArgs.builder()
MamManager.MamQueryArgs mamQueryArgs = builder.build();
MamManager.MamQuery mamQuery = mamManager.queryArchive(mamQueryArgs);


<iq to='muc_light_1@example.com' id='DUgMm-240' type='set'>
  <query xmlns='urn:xmpp:mam:1' queryid='a75f5d75-aac5-4625-9a77-e54ea605f7a0'>
    <x xmlns='jabber:x:data' type='submit'>
      <field var='FORM_TYPE' type='hidden'>
      <field var='start'>
    <set xmlns='http://jabber.org/protocol/rsm'>


<message from='muc_light_1@example.com' to='user1@example.com/mobile' id='56d97cef-131f-4265-9a59-f32dbaf89790'>
  <result queryid='a75f5d75-aac5-4625-9a77-e54ea605f7a0' xmlns='urn:xmpp:mam:1' id='B651C6UHK5G1'>
    <forwarded xmlns='urn:xmpp:forward:0'>
      <delay xmlns='urn:xmpp:delay' stamp='2019-12-01T09:49:40Z' from='muc_light_1@example.com/user2@example.com'></delay>
      <message from='muc_light_1@example.com/user2@example.com' to='' xmlns='jabber:client' id='e81d40f4-c86d-474f-a9e7-e06cd8cb3857' type='groupchat'>
        <item-type xmlns='custom.example.com' type='1' mime-type=''/>
        <markable xmlns='urn:xmpp:chat-markers:0'/>

<r xmlns='urn:xmpp:sm:3'/>

<message from='muc_light_1@example.com' to='user1@example.com/mobile' id='db60769e-7c35-4ebe-bf1e-70b0dd82d823'>
  <result queryid='a75f5d75-aac5-4625-9a77-e54ea605f7a0' xmlns='urn:xmpp:mam:1' id='B651F4M6HHG1'>
    <forwarded xmlns='urn:xmpp:forward:0'>
      <delay xmlns='urn:xmpp:delay' stamp='2019-12-01T09:56:13Z' from='muc_light_1@example.com/user2@example.com'></delay>
      <message from='muc_light_1@example.com/user2@example.com' to='' xmlns='jabber:client' id='c04dd394-e582-45c3-b104-6012a60debbd' type='groupchat'>
        <item-type xmlns='custom.example.com' type='1' mime-type=''/>
        <markable xmlns='urn:xmpp:chat-markers:0'/>

<message from='muc_light_1@example.com' to='user1@example.com/mobile' id='52802079-f623-4848-9d63-2f205c5ff3b8'>
  <result queryid='a75f5d75-aac5-4625-9a77-e54ea605f7a0' xmlns='urn:xmpp:mam:1' id='B651FD4A7D01'>
    <forwarded xmlns='urn:xmpp:forward:0'>
      <delay xmlns='urn:xmpp:delay' stamp='2019-12-01T09:56:49Z' from='muc_light_1@example.com/user2@example.com'></delay>
      <message from='muc_light_1@example.com/user2@example.com' to='' xmlns='jabber:client' id='50136ba9-70da-4b9a-a71e-baf9a69161e1' type='groupchat'>
        <item-type xmlns='custom.example.com' type='1' mime-type=''/>
        <markable xmlns='urn:xmpp:chat-markers:0'/>

The XMPP stanzas that are forwarded to you seem to have an empty to attribute. That’s suspicious to me.

@guus I’ve just read this https://github.com/esl/MongooseIM/pull/2220 and have patched MongooseIM to not send an empty to.

Thank you.

The MongooseIM pull request refers to an archived version of the MAM specification. The current version (0.6.3) specifies this:

When sending out the archives to a requesting client, the forwarded stanza MUST NOT have a ‘to’ attribute, and the ‘from’ MUST be the occupant JID of the sender of the archived message.

It is relevant to notice that between the versions that Mongoose refers to, and the current version, there was a namespace bump in the protocol. This typically signifies that a change has been added that breaks backwards compatibility.

I have not taken the time to find the discussion on why the specification was changed in this way. It is likely that @Flow - the author of Smack - has, and has chosen to explicitly make Smack fail in such a case. Maybe he can elaborate if it’s possible to have Smack be more lenient, but given the namespace bump, I think it’s unlikely.

In any case, updating Mongoose so that it no longer breaks the (most recent) version of the MAM XEP seems like a good solution to me.

@guus FYI, version 3.5.0 of MongooseIM already contains this update (to not send an empty to).