Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XMPP4r - Unable to Retrieve Offline Messages

I am trying to get openfire multi user group chat history using ruby xmpp4r library with openfire server. I am able to frame the request but I am not getting the server reply. Below is the discovery request

iqr = Iq.new(:get,"example.com")
iqr.add_namespace("http://jabber.org/protocol/disco#info")
client.send(iqr)

and this is the request that is framed

<iq to='example.com' type='get' xmlns='http://jabber.org/protocol/disco#info'/>

but I am not getting a server reply. I followed XEP-0160 and XEP-0013.

What am I missing here?


Does openfire provide room chat history? Is there an api for that?

Any help is deeply appreciated. And I dont understand openfire much so any information on it is very much appreciated.

like image 533
bapu Avatar asked Dec 26 '12 13:12

bapu


1 Answers

From what I know you can retrive chat history from a room only if that room was configured to be persisted and set to log converstions. There is also a limitation on how many days back the server returns history for. The limit used to be 2 days but there has been a longstanding discussion and some patches to fix that limitation.

According to another question here on SO it's not possible to retrive the history via a straight HTTP request without proxying the history through a separate XMMP server first, it that what you trying to do, or are you talking to the Openfire server?

In closing it looks like what you want would be possible. According to the XMPP spec. any new user would receive the full history of a room when joining, provided that the room was configured to send it. So, simply joining a properly configured room as a randomly created user would give you the history you are looking for.

So depending on if this is for a service you run or if you are trying to archive someone else's server your milage may wary. If you set up the server it looks to be possible, even if not by a specific API call. If the service is without your control however you might be out of luck since the history might simply not be there ...

Hope that helped you a bit even if I can not give a specific solution.

Service discovery

According to the documentation for service discovery your request is not complete:

<iq type='get'
    from='[email protected]/orchard'
    to='plays.shakespeare.lit'
    id='info1'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>

Maybe you should read up a bit on how to make a basic connection to an XMPP service using the gem? This looks to be what you need to get started. They have a lot of examples that should help you out quite a bit with the gem specifics ...

like image 144
Jonas Schubert Erlandsson Avatar answered Oct 03 '22 20:10

Jonas Schubert Erlandsson