Smack 连接到服务器失败
我在 Macbook 上成功设置了 ejabberd 服务器,并使用 iChat 和 Adium 对其进行了测试。我正在尝试设置 Jabberd/XMPP 客户端以在 Android 操作系统上工作。以下代码在 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 清单中:
<uses-permission android:name="android.permission.INTERNET" />
I setup an ejabberd server on my Macbook successfully, and tested it with iChat and Adium. I am trying to setup a Jabberd/XMPP client to work on the Android OS. The following code throws an exception on the connection.connect()
method:
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);
}
The following exception was created on the connection.connect()
method call:
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
I have the only following permission in the Android Manifest:
<uses-permission android:name="android.permission.INTERNET" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.local
下的名称由 多播 DNS 解析,并非所有软件可以处理这个问题。在本地测试时,您可以将其条目添加到您的/etc/hosts< /代码> 文件
。
Names under
.local
are resolved by multicast DNS, and not all software can handle that. While testing locally, you could add an entry for it to your/etc/hosts
file.