11

I fetched History from openfire by installing open fire plugin in the open fire and tried this code.

let iq1 = DDXMLElement(name: "iq")
    iq1.addAttribute(withName: "type", stringValue: "get")
    iq1.addAttribute(withName: "id", stringValue: "0")
    let retrieve = DDXMLElement(name: "retrieve", xmlns: "urn:xmpp:archive")
    retrieve?.addAttribute(withName: "with", stringValue: "raman@ip-172-31-53-77.ec2.internal")
    let set = DDXMLElement(name: "set", xmlns: "http://jabber.org/protocol/rsm")
    let max = DDXMLElement(name: "max", stringValue: "50")
    iq1.addChild(retrieve!)
    retrieve?.addChild(set!)
    set?.addChild(max)
    stream?.send(iq1 )

Now i am not getting history from Both Side. here is the result that i get.

<iq xmlns="jabber:client" 
type="result" 
id="0" 
to="bentick@ip-172-31-53-77.ec2.internal/5qsinh1syg">

<chat xmlns="urn:xmpp:archive" 
with="raman@ip-172-31-53-77.ec2.internal" 
start="2017-02-07T06:28:33.691Z">

 <from secs="0">
 <body>hello</body>
 </from>

 <from secs="405">
 <body>hiii</body>
 </from>

 <from secs="580">
 <body>Hey</body>
 </from>

 <from secs="599">
 <body>HooooE</body>
 </from>

 <from secs="628">
 <body>hOo</body>
 </from>

 <from secs="907">
 <body>Raman here</body>
 </from>
 
 <from secs="931">
 <body>Raman here ONE</body>
 </from>

 <from secs="1273">
 <body>Raman here</body>
 </from>

 <from secs="1558">
 <body> Raman from SPark </body>
 </from>

 <from secs="1571">
 <body> Raman from SPark One</body>
 </from>

 <from secs="1782">
 <body>Raman from SPark </body>
 </from>

 <from secs="2651">
 <body>Raman FiVE</body>
 </from>

 <from secs="2810">
 <body>Raman Three</body>
 </from>

 <from secs="2810">
 <body>Raman FOur</body>
 </from>

 <from secs="3534">
 <body>RAMAN SIX</body>
 </from>

 <from secs="4105">
 <body>Raman OKK</body>
 </from>

 <from secs="4113">
 <body>OKKK l</body>
 </from>

 <from secs="4130">
 <body>UST</body>
 </from>

 <set xmlns="http://jabber.org/protocol/rsm">
  <first index="0">0</first>
  <last>17</last>
  <count>18</count>
 </set>
</chat>
</iq>

This is all the message of RAMAN not BENTICk as this two user involved in chatting while getting history i only get the message of RAMAN. not BENTICk How to get history from both side user.

Please help.

Kirit Vaghela
  • 12,572
  • 4
  • 76
  • 80
Mad Burea
  • 531
  • 8
  • 22
  • are you using LDAP or in built openfire database? – OlaB Feb 07 '17 at 13:11
  • it's Default openfire database. – Mad Burea Feb 07 '17 at 13:15
  • have you Enabled Message auditing from Server > server settings -> Message Audit Policy? – OlaB Feb 07 '17 at 13:16
  • What about Server -> Archiving -> Archiving settings (message and meta-data settings)? – OlaB Feb 07 '17 at 13:19
  • If you make changes you need to restart the server to take effect – OlaB Feb 07 '17 at 13:21
  • There folder log, maximum size of all files is 1000 mb, maximum file size 10 mb,Maximum days to archive: -1,Flush Interval (seconds):120, and Packets to audit: nothing is checked. Ignore packets from/to users: nothin is written. Queued packets: 0 In Message Audit Policy is there is need to change anything – Mad Burea Feb 07 '17 at 13:21
  • Archiving setting is enabled and added idle time 10 both check one to one archiving and group chat, max time 60 max message age 60 and retrieval message 30 days – Mad Burea Feb 07 '17 at 13:23
  • you need to check conversation state archiving, to enable you fetch history, or whatever state you prefer. – OlaB Feb 07 '17 at 13:26
  • the last thing I can think of is are you able to pull the Roster of all clients? I have a chat API and once I log in all histories are auto fetched by pulling Rosters. – OlaB Feb 07 '17 at 13:28
  • Yes i pulled all Roster. and when one login i get all Offline Message.. OFFLINE MESSAGE not whole conversation – Mad Burea Feb 07 '17 at 13:29
  • well the last thing I can advise is that you have proper listeners for the chat messages, and any other types maybe group chat. If your packet listeners are good and all the settings are correct, you should not only get offline history but all history, there was also a setting in openfire that I changed which specifically asks of histories, it asks how many days you want to back date history and if you want all history from users saved, its there if you need help I can direct you towards it, but once I did that I got all history. Openfire is a bit hard for info. – OlaB Feb 07 '17 at 13:37
  • Go to Group Chat -> Group Chat settings -> History settings and see if you have it well setup, it might affect two users as well as multiple users. Good luck! – OlaB Feb 07 '17 at 13:44
  • I have changes their Show Entire Chat History by replacing Show a Specific Number of Messages that was 25. but still same issue – Mad Burea Feb 08 '17 at 04:05
  • Hi Mad, you asked for "chat" messages 1vs1 and all seems to be correct. Are you triyn' to retreive groupchat messages indeed?? – MrPk Feb 08 '17 at 08:53
  • @MrPk No it's One to one chat message retrieval not group chat – Mad Burea Feb 08 '17 at 09:00
  • Ok, to me your IQ seems correct. I really don't know what happens, what I can suggest, like a mother that asks if you already looked for shorts in proper drawer, if message "to" are actually stored in database (maybe you missed to save) and if the provided reply it's the Openfire one or what you parsed (in this case, check with a client like Spark against the same Openfire if the same request has the same reply, if not the issue is on client that ignores "to" tags) – MrPk Feb 08 '17 at 09:13
  • 1
    @MrPk I have checked so many Time where i am doing wrong. But don't know why this happen confused from Two days. still not getting any solutions... – Mad Burea Feb 08 '17 at 09:18
  • @MadBurea Please confirm from Openfire database (ofMessageArchive table) that if your messages exist there? The plugin reads messages from here and adds "from", "to" tags on that basis. – Shoaib Ahmad Gondal Feb 09 '17 at 13:32
  • @ShoaibAhmadGondal Yes i can see my message in Archive setting. Each and every message is there even All conversation message is present there.. – Mad Burea Feb 09 '17 at 13:35

1 Answers1

-1

I have implemented the same to get the Message to and from by sending the given iq And I am getting the proper result.

let iQ = DDXMLElement.element(withName: "iq") as! DDXMLElement
        iQ.addAttribute(withName: "type", stringValue: "get")
                iQ.addAttribute(withName: "id", stringValue: (xmppHandler.xmppStream?.generateUUID())!)
        let retrieve = DDXMLElement(name: "retrieve", xmlns: "urn:xmpp:archive")
        retrieve?.addAttribute(withName: "with", stringValue: "\(JID!)@\(Utility.hostname)")

        let set = DDXMLElement.element(withName: "set") as! DDXMLElement
        set.addAttribute(withName: "xmlns", stringValue: "http://jabber.org/protocol/rsm")
        let max = DDXMLElement.element(withName: "max") as! DDXMLElement
        max.stringValue = "10"
        max.addAttribute(withName:"xmlns", stringValue: "http://jabber.org/protocol/rsm")

        iQ.addChild(retrieve!)
        retrieve?.addChild(set)
        set.addChild(max as DDXMLNode)
        xmppHandler.xmppStream?.send(iQ)

<iq type="get" id="7705EEC5-3385-42D4-B748-B39C204ADB90"><retrieve xmlns="urn:xmpp:archive" with="0544008296@192.168.2.181"><set xmlns="http://jabber.org/protocol/rsm"><max xmlns="http://jabber.org/protocol/rsm">10</max></set></retrieve></iq>

Response

    <iq xmlns="jabber:client" type="result" id="7705EEC5-3385-42D4-B748-B39C204ADB90" to="0509503847@192.168.2.181/Smack">
  <chat xmlns="urn:xmpp:archive" with="0544008296@192.168.2.181" start="2017-02-28T09:55:27.068Z">
    <from secs="0" jid="0544008296@192.168.2.181">
      <body>Hiii rajeev</body>
    </from>
    <to secs="52">
      <body>Hi
        How r u</body>
    </to>
   <from secs="15" jid="0544008296@192.168.2.181"><body>I am good</body></from>
   <to secs="8"><body>What abt u</body></to>
   <to secs="169"><body>Hello testing chat</body></to>
   <from secs="10" jid="0544008296@192.168.2.181"><body>Good</body></from>
   <from secs="5" jid="0544008296@192.168.2.181"><body>Continue </body></from>
   <to secs="834"><body>Ok
    </body></to>
   <to secs="8"><body>Nice chat
    </body></to>
   <from secs="232" jid="0544008296@192.168.2.181"><body>Heelo</body></from>
   <set xmlns="http://jabber.org/protocol/rsm"><first index="0">0</first>     <last>9</last><count>574</count></set></chat></iq>
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103