我目前正在开发android XMPP客户端以与Tigase服务器设置进行本地通信。在Android上开始开发之前,我正在编写一个简单的Java代码以测试与XMPP服务器的连接。我的XMPP域名是我的电脑名称“mwbn43-1”,管理员用户名和密码分别是admin和tigase。Smack API在本地登录到Tigase Server设置时出错
以下是代码我使用
class Test {
public static void main(String args[])throws Exception
{
System.setProperty("smack.debugEnabled", "true");
XMPPConnection.DEBUG_ENABLED = true;
ConnectionConfiguration config = new ConnectionConfiguration("mwbn43-1", 5222);
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);
XMPPConnection con = new XMPPConnection(config);
// Connect to the server
con.connect();
con.login("admin", "tigase");
Chat chat = con.getChatManager().createChat("[email protected]",
new MessageListener() {
public void processMessage(Chat chat, Message message) {
// Print out any messages we get back to standard out.
System.out.println("Received message: " + message);
}
});
try {
chat.sendMessage("Hi!");
}
catch (XMPPException e) {
System.out.println("Error Delivering block");
}
String host = con.getHost();
String user = con.getUser();
String id = con.getConnectionID();
int port = con.getPort();
boolean i = false;
i = con.isConnected();
if (i)
System.out.println("Connected to host " + host + " via port " + port + " connection id is " + id);
System.out.println("User is " + user);
con.disconnect();
}
}
当我运行这段代码我获得以下错误
Exception in thread "main" Resource binding not offered by server:
at org.jivesoftware.smack.SASLAuthentication.bindResourceAndEstablishSession(SASLAuthenticatio n.java:416) at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:331)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:349)
at Test.main(Test.java:26)
我发现了同样的问题,这个文章,但没有具体的解决方案 片断here 任何人都可以告诉我这个问题的解决方案。我检查了Smack API中的XMPPConnection.java文件,它看起来与链接解决方案中给出的相同。
感谢, Ameya
我应该怎么为了使它正常工作。我尝试了与Gtalk服务器相同的代码,并且它的工作正常。所以我想问题是服务器的设置问题(某些资源问题)。我应该在服务器端做什么? – 2010-06-06 07:28:18