我試圖發現pubsub服務提供的項目。當我登錄到目標服務器時,我可以成功獲得響應。但是當我連接的時候不要登錄,它會給出錯誤的請求。沒有登錄的Smack服務發現提供不良請求(400)
這是代碼:
ConnectionConfiguration config = new ConnectionConfiguration(serverAddress, 5222);
config.setServiceName(serviceName);
connection = new XMPPConnection(config);
connection.connect();
connection.login(userName, password); //!!!when I remove this line, bad request error is received
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items;
try {
items = discoManager.discoverItems("pubsubservice." + serverName);
} catch (XMPPException e) {
e.printStackTrace();
}
有沒有一種方法來發現,當用戶沒有登錄項目,但在建立連接?