unknown host exception coming while connecting to ejabberd server.
连接到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);
}
any answer will be appreciable ! thanks
任何答案都会很明显!谢谢
2 个解决方案
#1
5
Traditional XMPP doesn't use HTTP
传统的XMPP不使用HTTP
You can't connect to http://54.254.220.129:5280/admin
(this is for browsers!)
您无法连接到http://54.254.220.129:5280/admin(这适用于浏览器!)
You need to use just the IP address
您只需要使用IP地址
public static final String HOST = "54.254.220.129";
#2
3
In your HOST string you already wrote the port number. So i think you need to write only ip address without port and admin like http://54.254.220.129
. - After that try to connect. And try to login.
在您的HOST字符串中,您已经编写了端口号。所以我认为你只需要编写没有端口的ip地址和管理员,如http://54.254.220.129。 - 之后尝试连接。并尝试登录。
Try this;
尝试这个;
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);
#1
5
Traditional XMPP doesn't use HTTP
传统的XMPP不使用HTTP
You can't connect to http://54.254.220.129:5280/admin
(this is for browsers!)
您无法连接到http://54.254.220.129:5280/admin(这适用于浏览器!)
You need to use just the IP address
您只需要使用IP地址
public static final String HOST = "54.254.220.129";
#2
3
In your HOST string you already wrote the port number. So i think you need to write only ip address without port and admin like http://54.254.220.129
. - After that try to connect. And try to login.
在您的HOST字符串中,您已经编写了端口号。所以我认为你只需要编写没有端口的ip地址和管理员,如http://54.254.220.129。 - 之后尝试连接。并尝试登录。
Try this;
尝试这个;
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);