8

I'm using ejabberd 15.09 and have enabled archive management for every MUC in the server configuration like below:

mod_mam:
    default: always
 mod_muc:
    ## host: "conference.@HOST@"
    access: muc
    access_create: muc_create
    access_persistent: muc_create
    access_admin: muc_admin
    default_room_options:
      mam: true
      persistent: true
      public: true

Also inspection on the admin panel for Ejabberd shows that messages are getting archived as the number of elements in archive table goes up after each message is sent to the MUC. This is verifying that archiving is enabled for the session.

To query the server for message archive from MUC, I am sending this iq packet:

<iq type='set' id='testid1'>
      <query xmlns='urn:xmpp:mam:1'>
        <x xmlns='jabber:x:data' type='submit'>
           <field var='FORM_TYPE' type='hidden'>
               <value>urn:xmpp:mam:1</value>
           </field>
          <field var='with'>
             <value>testmyroomnow@conference.ip/</value>
          </field>
       </x>
      </query>
    </iq>

Response received from the server doesn't contain any messages.

<message from='user@ip' to='user@ip/Gajim'>
<fin xmlns='urn:xmpp:mam:0' complete='true'>
<set xmlns='http://jabber.org/protocol/rsm'>
<count>0</count>
</set>
</fin>
</message>

This MUC already contains some messages but querying like above is not returning any message. It seems that the format of xml stanza is not correct. Either the format for sending JID for conference is not correct or something else.

Not sure what to do as I'm already using the latest version of Ejabberd which is showing to support archive of MUC. Other that what I'm doing here, I have no idea how to query a MUC archive from ejabberd server.

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
BeinTouch
  • 107
  • 5

1 Answers1

4

You need to query the MUC service for MUC archive. The user MAM service only stores message for one-to-one conversation.

Please also note that you are not using the latest ejabberd. As of today, latest version is 15.11. I recommend you use the latest one regarding MAM MUC, as several clarifications has been made to XEP-0313 and were added to latest ejabberd.

Here is example query, sending MAM query stanza to MUC room itself:

<iq type='set' id='juliet1' to='tech@conference.process-one.net'>
  <query xmlns='urn:xmpp:mam:0' queryid='f27'>
  <set xmlns='http://jabber.org/protocol/rsm'>
        <max>10</max>
      </set>
  </query>
</iq>
Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
  • Are you referring that for querying MUC archive, I need to send use the value of the 'to' attribute as the target JID ()? If I do this way, I get feature not implemented error. Does this mean Archiving of MUC is not taking place? This is confusing because database entries show that archiving is happening. Also to upgrade the latest version to 15.11, is it to possible to upgrade without restarting or stopping the current running version? Because if I upgrade by stopping/restarting, I will all messages in room history as it is stored in RAM. – BeinTouch Jan 12 '16 at 16:26
  • Yes, unfortunately the XEP has no example. However, you need to send the stanza to the MUC room itself and make sure you use ejabberd 15.11. It was implemented with custom stanza before as the use case was not covered by XEP when we first implemented it. – Mickaël Rémond Jan 12 '16 at 16:30
  • It is not possible to upgrade to ejabberd 15.11 without stopping the server. – Mickaël Rémond Jan 12 '16 at 16:32
  • Ok. thanks. I will upgrade to 15.11 now and report if it works. – BeinTouch Jan 12 '16 at 16:33
  • Just made a fresh installation of 15.11. when I specify the To attribute as the target JID (), it gives the same Feature Not implemented error. 501 error code. This time also archive table is getting updated as I can see from admin panel, which shows that MUC archive is working. Can you please post the xml stanza that needs to be sent for query? XEP documentation is really not sufficient. Thanks. – BeinTouch Jan 12 '16 at 18:42
  • I just tried the xml stanza as you wrote above. It gives feature not implemented. – BeinTouch Jan 12 '16 at 18:56
  • XEP says that A MUC service allowing MAM queries for a room MUST expose the MAM archive on the room's bare JID. Do we need to something in the configuration file (ejabberd.yml) to expose MUC to MAM queries? – BeinTouch Jan 12 '16 at 19:02
  • Try with namespace: urn:xmpp:mam:0. We found bug in code: support for new namespace was not added for that feature. – Mickaël Rémond Jan 13 '16 at 09:42
  • Yes. It worked with mam:0. This thread should solve issues which many others are facing with MUC archive as not much information in documentation. Thanks much. – BeinTouch Jan 14 '16 at 03:56
  • The problem is how can I query both one-to-one and MUC in one query? I really need a query to cover both cases – CodingTT Mar 29 '17 at 20:58
  • hi, i use smack library for android, how i cam get messeages in muc with using mam manager? – Тони Jan 22 '20 at 11:04