0
votes

Here's what I'm using: Openfire 3.10.2 Smack 4.1.3 Environment: Android

I'm trying to search for a registered user, but I kept failing to do so. I've tried so many different combinations. I also tried on an older version of smack. Here's my latest modified code:

UserSearchManager userSearchManager = new UserSearchManager(connection);
    Form searchForm = null;
    List<ReportedData.Row> list = null;
    try {
        userSearchManager.getSearchForm("search." + connection.getServiceName());
        Form answerForm = searchForm.createAnswerForm();
        answerForm.setAnswer("Username", true);
        answerForm.setAnswer("search", userName);
        answerForm.setAnswer("Name", true);
        answerForm.setAnswer("search", userName);
        ReportedData data = userSearchManager.getSearchResults(answerForm, "search." + connection.getServiceName());
        list = data.getRows();
    } catch (SmackException.NoResponseException e) {
        e.printStackTrace();
    } catch (XMPPException.XMPPErrorException e) {
        Log.e(LOG_TAG, e.getMessage());

    } catch (SmackException.NotConnectedException e) {
        Log.e(LOG_TAG, e.getMessage());
    }

I would get this error org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: remote-server-not-found - cancel on line,

    Form searchForm = manager.getSearchForm("search." + connection.getServiceName());

I don't know if I missed configure something on openfire server, or do I need to setup something before I start searching. My workaround idea was to get the full list of registered users and then search from there, but I'm not sure how to achieve that. Once I logged in, the roster only consists of my friends and groups. Could someone point me to the right direction?

1

1 Answers

1
votes

You're trying to search for users on the server "search." + connection.getServiceName(), but your server is telling you that it can't find that server. It looks like you did not set up a search server in OpenFire, or you're using the wrong address.