powered by Jive Software

Retrieve chat history using smack in android


I am implementing chat with Smack 4.1.7 for android, and i would like to know if it is now possible to retrieve chat history. I read some posts on StackOverflow dated June 2015, and that point in time they said that this support has not been added. Will you please let me know if this support exists? Also, if it does, where could i get a code reference of the same?



About chat (“chat”) history no, you need to implement by yourself client side or both server/client.

About “groupchat” it exists, it can appear tricky but just enable on conference SERVICE the history

multiUserChatManager.getMultiUserChatService(“conference”).getHistoryStrategy(). setType(HistoryStrategy.Type.all);

and all the groupchat in the service will send the history automatically (it’s possible to limit days for history with param: xmpp.muc.history.reload.limit in days)


Thanks alot for the reply. Will you please let me know how to create a multi user chat using smack v4.1.7 ? I have to create a multi user chat for maintaining a chat history?

Also, i get an error: “cannot resolve method name getMultiUserChatService(String string)” when i try using the code you have provided.

look at this tutorial: http://download.igniterealtime.org/smack/docs/latest/documentation/extensions/mu c.html

I tried using the link and i manged to write this:

public MultiUserChat createGroupChat() {

// Get the MultiUserChatManager
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection);

// Get a MultiUserChat using MultiUserChatManager
MultiUserChat muc = manager.getMultiUserChat("myroom@domain.com");

try {

// Create the room

// Send an empty room configuration form which indicates that we want
// an instant room
muc.sendConfigurationForm(new Form(DataForm.Type.submit));

DiscussionHistory history = new DiscussionHistory();


muc.join(Global.user1 + "@domain.com","",history, SmackConfiguration.getDefaultPacketReplyTimeout() );

}catch (SmackException e) {


} catch (XMPPException.XMPPErrorException e) {



return muc;


but i get the following error:

org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). Used filter: AndFilter: (FromMatchesFilter (full): myroom@domain.com/testbot, StanzaTypeFilter: Presence).

SENT (0):

07-20 09:40:31.536 11138-13109/samplechatapp D/SMACK: RECV (0):

07-20 09:40:31.540 11138-11138/samplechatapp W/System.err: org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: service-unavailable - cancel

Can you please assist?


Sorry for short reply.

Muc must be created in a conference service (look in Admin panel).

Openfire creates a defaullt conference service named “conference”, so basically you can create something like:


hope that helps


how do i retrieve the chat history ? Once i join the group ? Please advice.


Have you found solution for that? I am also facing same issue.

Resurrecting old threads is not a good idea. Start new one instead.

As of your question, have you checked MAM?

Yes, I already tried that, MaM return 0 messages while there are already many messages.