It's been more than 6 hours I'm stuck at this issue, I have checked hundreds of solutions over internet but nothing works for me.
I'm implementing an XMPP Android client via Smack 4.2, following are my gradle dependencies:
compile "org.igniterealtime.smack:smack-android-extensions:4.2.0"
compile "org.igniterealtime.smack:smack-tcp:4.2.0"
I've declared permission in manifest:
<uses-permission android:name="android.permission.INTERNET" />
Here is my code to connect to server
private class LoginTask extends AsyncTask<UserProps, String, String> {
@Override
protected String doInBackground(UserProps... props){
try {
InetAddress addr = InetAddress.getByName("192.168.100.5");
HostnameVerifier verifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return false;
}
};
DomainBareJid serviceName = JidCreate.domainBareFrom("rabta");
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword(props[0].getUser(), props[0].getPass())
.setHostAddress(addr)
.setXmppDomain(serviceName)
.setHostnameVerifier(verifier)
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setPort(5222)
.setDebuggerEnabled(true)
.build();
AbstractXMPPConnection conn = new XMPPTCPConnection(config);
conn.connect();
if(conn.isConnected()) {
Log.w("app", "connected--------------------------");
}
conn.login();
if(conn.isAuthenticated()) {
Log.w("app", "authenticated----------------------");
}
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
}
return "";
}
@Override
protected void onPostExecute(String result) {
}
}
Where 192.168.100.5
is the ipv4 address of windows 10 machine on which ejabberd is installed. rabta
is the name of my server which I specified instead of localhost
at the time of installation. My server is not on a live IP. My client and server, both are on same WiFi network.
org.jivesoftware.smack.SmackException$ConnectionException: The following addresses failed: 'null:5222' failed because: /192.168.100.5
exception: java.net.ConnectException: failed to connect to /192.168.100.5 (port 5222) after 30000ms: isConnected failed: ECONNREFUSED (Connection refused)
01-05 05:16:19.757 18413-18591/com.rabta.rabta W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPConnection.java:617)
The message I receive on starting ejabberd
By default, the ejabberd Web Admin interface is enabled. You should be able to connect to the admin interface and log in with the user admin@rabta and the password you defined during the installation.
Users can connect to your server 'rabta' with any Jabber/XMPP
The name of the current ejabberd node is ejabberd@localhost.
User credentials to login: username user1@rabta
password pass
and finally the ejabberd.yml
hosts:
- "rabta"
listen:
-
port: 5222
ip: "::"
module: ejabberd_c2s
starttls: true
On server machine I have admin privileges and all the firewalls are turned off. I'd be very glad If somebody could help me. Thanks in advance