我在Macbook上成功设置了 ejabberd 服务器,并使用iChat和Adium进行了测试。我正在尝试设置Jabberd / XMPP客户端以在Android OS上工作。以下代码在connection.connect()
方法上抛出异常:
public void login(String username, String password) throws XMPPException {
ConnectionConfiguration config = new ConnectionConfiguration("my-ejabberd-server-macbook.local", 5222);
connection = new XMPPConnection(config);
XMPPConnection.DEBUG_ENABLED = true;
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
connection.connect();
connection.login(username, password);
}
在connection.connect()
方法调用上创建了以下异常:
XMPPError connecting to my-ejabberd-server-macbook.local:5222.: remote-server-error(502) XMPPError connecting to my-ejabberd-server-macbook.local:5222.
-- caused by: java.net.SocketException: Host is unresolved: my-ejabberd-server-macbook.local
我在Android Manifest中拥有以下唯一权限:
<uses-permission android:name="android.permission.INTERNET" />