1
今天早上我遇到了一個複雜的問題。 我正在使用XMPP創建聊天應用程序。我已成功登錄並可以與用戶聊天。用戶搜索管理器中出現XMPP服務不可用(503)錯誤
現在,我想在XMPP服務器中搜索用戶。但我得到了錯誤服務不可用(503)
這是我的代碼: -
UserSearchManager usm = new UserSearchManager(connection);
Form searchForm = usm.getSearchForm("search."+connection.getServiceName());
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
answerForm.setAnswer("search", "[email protected]");
ReportedData data = usm.getSearchResults(answerForm, "search."+connection.getServiceName());
System.out.println("data is "+data);
還有一點。當我使用getSearchServices()訪問http://www.igniterealtime.org/builds/smack/docs/3.2.2/javadoc/org/jivesoftware/smackx/search/UserSearchManager.html#getSearchServices()。我得到了零的值。
這是代碼: -
UserSearchManager usm = new UserSearchManager(connection);
System.out.println(usm.getSearchServices().size());
我有我的XMPP服務器安裝高級搜索插件。但仍然沒有產出。
還是得到了同樣的錯誤鍵入的名字! – user2160008
我綁定你的代碼。它爲我工作。您是否將代碼添加到您的代碼和使用的任何版本? – AwadKab
Sry我沒有得到。這是我的連接代碼。 ** String host =「xxx.xxx.xxx.xxx」; \t \t String port =「5222」; \t \t String service =「xxx.xxx.xxx.xxx」; \t \t String username =「xxx」; \t \t String password =「xxx」; ConnectionConfiguration connConfig = new ConnectionConfiguration(host,Integer.parseInt(port),service); connection = new XMPPConnection(connConfig); connection.connect(); connection.login(username,password);存在狀態=新存在(Presence.Type.available); \t \t connection.sendPacket(presence); ** – user2160008