连接到ejabberd服务器时出现未知主机异常。
public static final String HOST = "http://54.254.220.129:5280/admin";
public static final int PORT = 5222;
public static final String SERVICE = "localhost";
public static final String USERNAME = "admin@localhost";
public static final String PASSWORD = "########";
ConnectionConfiguration connConfig = new ConnectionConfiguration(HOST, PORT, SERVICE);
XMPPConnection connection = new XMPPConnection(connConfig);
enter code here
try {
connection.connect();
Log.i("XMPPChatDemoActivity",
"[SettingsDialog] Connected to "
+ connection.getHost());
} catch (XMPPException ex) {
Log.e("XMPPChatDemoActivity",
"[SettingsDialog] Failed to connect to "
+ connection.getHost());
Log.e("XMPPChatDemoActivity", ex.toString());
setConnection(null);
}
任何答案都会很明显! 感谢
答案 0 :(得分:5)
传统XMPP不使用HTTP
您无法连接到http://54.254.220.129:5280/admin
(这适用于浏览器!)
您只需要使用IP地址
public static final String HOST = "54.254.220.129";
答案 1 :(得分:3)
在您的HOST字符串中,您已经编写了端口号。所以我认为你只需要编写没有端口的ip地址和像http://54.254.220.129
这样的管理员。
- 之后尝试连接。并尝试登录。
试试这个;
public static final String HOST = "http://54.254.220.129";
public static final int PORT = 5222;
public static final String SERVICE = "localhost";
public static final String USERNAME = "admin@localhost";
public static final String PASSWORD = "########";
ConnectionConfiguration connConfig = new ConnectionConfiguration(HOST, PORT, SERVICE);
XMPPConnection connection = new XMPPConnection(connConfig);
connection.connect();
connection.login(USERNAME, PASSWORD);