Retrieve history chat Openfire XMPP framework
Asked Answered
O

1

1

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?

Obstreperous answered 26/8, 2016 at 10:4 Comment(10)
Are you getting only those messages which were sent by you in group?Deltadeltaic
@ShoaibAhmadGondal No. As you can see the result, 2 of them was sent by me, and the other was sent by haha@macintoshObstreperous
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.Deltadeltaic
Oh, I realized that messages belongs to different conversations. Tks for your answerObstreperous
@ShoaibAhmadGondal When chat 1 vs 1, the conversation id has changed after login/logout. Do you know how to make them have same conversation id?Obstreperous
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?Deltadeltaic
Hi maphongba008, how to use XEP-0136 to archieve history.I was strucked here, can you please helpSandasandakan
@Sandasandakan I sent the iq in the accepted answer and it workedObstreperous
@ maphongba008, I am troubling in how to send the iq and receive the iq in smack.Sandasandakan
@Sandasandakan I haven't worked with smack, I use Swift with XMPPFrameworkObstreperous
P
3

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

Pul answered 30/8, 2016 at 20:3 Comment(2)
its not working i got error in response <iq xmlns="jabber:client" type="error" id="a5sV8-21" to="aplostester_5811e47ad5945@ip-172-31-4-183/a1i7hf9aho"><query xmlns="urn:xmpp:mam:1" queryid="12345678"><x xmlns="jabber:x:data" type="submit"><field var="FORM_TYPE" type="hidden"><value>urn:xmpp:mam:1</value></field><field var="with"><value>test32_5811a995837c2@ip-172-31-4-183</value></field></x><set xmlns="jabber.org/protocol/rsm"><max>100</max></… code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></service-unavailable></error></iq>Labiche
It says the feature is not enabled in your server. Enable the feature it will work.Pul

© 2022 - 2024 — McMap. All rights reserved.