Smack 4.2.3 MamManager not returning chatHistory

Hi
I am trying to implement a java smack client interacting with Openfire server. I have added the plugin for Monitoring service, also enabled archiving. Now I can see the chat history in the openFire Admin Console. I would like to do the same using Smack. This is the code I have written.

	XMPPTCPConnection connection = connectToXMPP(Constants.XMPPADMINUSERNAME, Constants.XMPPADMINPWD ,Constants.XMPPDOMAIN);

    MamManager mamManager = MamManager.getInstanceFor(connection);
    try {
        DataForm form = new DataForm(DataForm.Type.submit);
        FormField field = new FormField(FormField.FORM_TYPE);
        field.setType(FormField.Type.hidden);
        field.addValue(MamElements.NAMESPACE);
        form.addField(field);

        FormField formField = new FormField("with");
        formField.addValue("userlocal1@125.99.44.122");
        form.addField(formField);
        boolean isSupported = mamManager.isSupported();
        // "" empty string for before
        RSMSet rsmSet = new RSMSet(maxResults, "", RSMSet.PageDirection.before);
        MamManager.MamQueryResult mamQueryResult = mamManager.page(form, rsmSet);
       // MamManager.MamQueryResult mamQueryResult1 = mamManager.queryArchive(JidCreate.from("userlocal1@125.99.44.122"));
        return mamQueryResult;

    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;

Now the problem is the forwardedMessages ArrayList is always null. What am I doing wrong?? isSupported is true and I can see the chathistory on admin console… Please guide…

Have you read the documentation?

1 Like

Yes…Am using the same method calls.

Have you tried the simplest case?

MamQueryResult mamQueryResult = mamManager.queryArchive(max);

Also: It is really bad practice to use IPs as service name.

I know about the ip. But for the simplest case there was no option. Will change it when moving to deployment to prod.

MamQueryResult mamQueryResult = mamManager.queryArchive(max);

This gives an error - RSMSet cannot be null.

2 posts were split to a new topic: MAM query error result: “rsmSet must not be null”