How to uses Smack API UserSearchManager with local server?

人盡茶涼 提交于 2019-12-11 05:58:17

问题


This may look a very basic question but I am having a problem accessing OpenFire search function using this code:

    try {

        UserSearchManager search = new UserSearchManager(connection.getConnection());
        Form searchForm = search.getSearchForm("search." + server);
        ...

    } catch (Exception e) {...}

The server here is a String with value something like "192.168.242.132", the code gets error from this line: Form searchForm = search.getSearchForm("search." + server);

Essentially, the server is up and running as I can create account and login/logout.

I assume that the problem is with the "server" String value. Any one have encountered this kind of problem before?

EDIT: I have already added in /etc/hosts to resolve the IP address to myelastix-local.com and still having the same problem, it can access create / login api but search still does not work. Do I have to modify openfire server settings too?


回答1:


Are you sure that you can call getSearchForm() with an IP? Try to provide the component ID, which is normally something like "search.jabberserver.tld"




回答2:


Here's what I did:

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

connection is the XMPPConnection.



来源:https://stackoverflow.com/questions/7149928/how-to-uses-smack-api-usersearchmanager-with-local-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!