我正在尝试为IM做一个无服务器应用程序。我使用apple bonjour协议来发现xmpp服务。但一旦我得到那些我无法连接到我的主机(Linux电脑使用pidgin + bonjour)。Xmpp连接在Android上使用asmack和bonjour
这里是我的代码(从here拍摄):
public class Xmpp extends AsyncTask<Void, Void, Void>
{
@Override
protected Void doInBackground(Void... arg0)
{
ConnectionConfiguration connConfig =
new ConnectionConfiguration("192.168.0.11", 5298, "bonjour");
XMPPConnection connection = new XMPPConnection(connConfig);
try
{
// Connect to the server
connection.connect();
// Most servers require you to login before performing other tasks.
connection.login("grea08", "mypass");
// Start a new conversation with John Doe and send him a message.
Chat chat = connection.getChatManager().createChat("[email protected]", new MessageListener() {
public void processMessage(Chat chat, Message message) {
// Print out any messages we get back to standard out.
Log.v(getClass().getName(), "Received message: " + message);
}
});
chat.sendMessage("Howdy!");
} catch (XMPPException e)
{
// TODO Auto-generated catch block
Log.e(getClass().getName(), "Xmpp error !", e);
}
// Disconnect from the server
connection.disconnect();
return null;
}
}
我有一个XmppException
“服务器没有响应”。我认为主机不是XMPP服务器,我们必须使用协议this的方式。
它确实是'192.189 ...'而不是'192.168 ...'?大多数内部IP地址是192.168.something。 – Jave
啊是的一个简单的错误,谢谢,我正在努力 – grea09
不是这不会导致“没有反应”错误。 – grea09