I have an ejabberd XMPP server installed locally on a mac. I'm using this code to connect and login using Smack API on android.
config = XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword("[email protected]", "1")
.setHost("192.168.1.2")
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setServiceName("192.168.1.2")
.setPort(Integer.parseInt("5222"))
.build();
AbstractXMPPConnection conn2 = new XMPPTCPConnection(config);
try {
conn2.connect();
conn2.login();
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
}
Using the same username and password, Im able to login using any other XMPP client like Adium but the code above gives this error on android -
Connection closed with error org.jivesoftware.smack.XMPPException$StreamErrorException: host-unknown
My Local address is 192.168.1.2 and the ejabberd admin panel is localhost:5280/admin.
I read the documentation and did everything written. Any problem with the code or something here ?