XMPP4r - Unable to Retrieve Offline Messages
Asked Answered
J

1

8

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.

Jennyjeno answered 26/12, 2012 at 13:22 Comment(0)
F
1

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 ...

Fere answered 3/2, 2013 at 17:55 Comment(5)
I am using ruby xmpp4r add_message_callback on MUCClient to get group chat messages but its working asynchronously. how to change this behaviour to synchronous ?? how to return these messages from callback ??Jennyjeno
According to the code (github.com/ln/xmpp4r/blob/master/lib/xmpp4r/stream.rb#L351) you can give the send() method a block to make it wait for the response and it's parsing. And it looks like you could do the same with add_message_callback().Fere
I have created above xml stanza structure using xmpp4r and its parsed successfully but my basic question is that how to get corresponding response into any variable??Jennyjeno
Maybe you should read the examples they provide with the gem (github.com/ln/xmpp4r/tree/master/data/doc/xmpp4r/examples) or, if that doesn't help you, extend your question to include the relevant code. It's difficult to help with a problem that is now outside of what you have in your original question.Fere
I am using (#11397672) link to retrieve group chat history but while parsing this xmpp stanza server does not send any response. Is there is another way to get multi user group chat history??Jennyjeno

© 2022 - 2024 — McMap. All rights reserved.