1
votes

I've developed a chat app using XMPPframwork of Robbie Hanson and Openfire server. I can chat one to one and chat group successfully. But when I get history of chat, I can't get whole history. I use XEP-0136 to archieve history:

Send IQ:

 <iq type="get" id="hichic@macintosh">
    <retrieve
        xmlns="urn:xmpp:archive" with="[email protected]">
        <set
            xmlns="http://jabber.org/protocol/rsm">
            <max>100</max>
        </set>
    </retrieve>
</iq>

Receive:

<iq type="result" id="hichic@macintosh" to="admin@macintosh/Macintosh">
    <chat
        xmlns="urn:xmpp:archive" with="[email protected]" start="2016-08-23T08:42:55.777Z">
        <to secs="0">
            <body>asdf</body>
        </to>
        <to secs="5">
            <body>aafs</body>
        </to>
        <from secs="2" jid="haha@macintosh">
            <body>sax</body>
        </from>
        <set
            xmlns="http://jabber.org/protocol/rsm">
            <first index="0">0</first>
            <last>2</last>
            <count>3</count>
        </set>
    </chat>
</iq>

But when I open the database, ofMessageArchive table, I can see much more messages with group12 (~20 messages) while in the result, I only got 3. May I miss something?

1
Are you getting only those messages which were sent by you in group?Shoaib Ahmad Gondal
@ShoaibAhmadGondal No. As you can see the result, 2 of them was sent by me, and the other was sent by haha@macintoshmaphongba008
XEP-0136 implementation in monitoring plugin against your IQ Packet basically gathers data by querying three tables: ofConversation, ofConParticipant, ofMessageArchive. Can you check in your databases the references for the room which you are querying that data exists with relations in these three tables. As you already mentioned that data exists in ofMessageArchive.Shoaib Ahmad Gondal
Oh, I realized that messages belongs to different conversations. Tks for your answermaphongba008
New conversations are created if conversation's idleTime or maxTime has passed. So try to override the default values by defining properties from admin console. Values of Following two properties need to be override: conversation.idleTime = 10, conversation.maxTime = 60. Change 10, 60 (hours) to more suitable value and then try if issue is still there?Shoaib Ahmad Gondal

1 Answers

3
votes

Follow this format, it works for me perfectly,

<iq id='a5sV8-21' type='set'>
    <query xmlns='urn:xmpp:mam:0' queryid="12345678">
        <x xmlns="jabber:x:data" type="submit">
            <field var="FORM_TYPE" type="hidden"><value>urn:xmpp:mam:0</value></field>
            <field var="with"><value>id@domain</value></field>
        </x>
        <set xmlns="http://jabber.org/protocol/rsm">
            <max>message_count</max>
        </set>
    </query>
</iq>

** If xmpp:mam:0 doesn't work use xmpp:mam:1