Hi,
We are building android XMPP client from scratch .
Here are the development system configurations .
Windows 10.
Smack 4.3.1
server configurations:
OS: linux (ubuntu 18).
Server: Ejabberd 19.08
Hosted on system IP : 192.168.4.162 .
Domain: 192.168.4.162 .
JID Format: <user@192.168.4.162>
Here is My Code snippet:
img_continue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(LOGTAG,“User clicked on login”);
Runnable runnable=new Runnable() {
@Override
public void run() {
InetAddress addr = null;
try {
addr = InetAddress.getByName("192.168.4.162");
System.out.println("addr:"+addr);
} catch (UnknownHostException e) {
e.printStackTrace();
}
HostnameVerifier verifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return false;
}
};
XMPPTCPConnectionConfiguration connectionConfiguration = null;
try{
connectionConfiguration = XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword("alice", "9009")
.setXmppDomain("192.168.4.162")
.setHostAddress(addr)
.setPort(5222).
setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setKeystoreType(null)
.build();
}catch (XmppStringprepException e){
e.printStackTrace();
}
AbstractXMPPConnection connection = null;
connection = new XMPPTCPConnection(connectionConfiguration);
connection.addConnectionListener(new ConnectionListener() {
@Override
public void connected(final XMPPConnection connection) {
Log.d(LOGTAG,"chat Application- connected");
}
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {
Log.d(LOGTAG,"chat Application-authenticated");
}
@Override
public void connectionClosed() {
Log.d(LOGTAG,"chat Application- closed");
}
@Override
public void connectionClosedOnError(Exception e) {
Log.d(LOGTAG,"chat Application- connectionClosedOnError");
}
});
ChatManager chatManager= ChatManager.getInstanceFor(connection);
chatManager.addIncomingListener(new IncomingChatMessageListener() {
@Override
public void newIncomingMessage(EntityBareJid from, Message message, Chat chat) {
Log.d(LOGTAG,"Incoming message :" +message.getBody());
}
});
try {
connection.connect().login();
} catch (XMPPException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
Thread connectionThread = new Thread(runnable);
connectionThread.start();
}
});
It is causing this error continuously
-
Could not resolve DNS SRV resource records for _xmpp-client._tcp.192.168.4.162. Consider adding those.
-
SmackException$ConnectionException: The following addresses failed: ‘_xmpp-client._tcp.192.168.4.162:5222’ failed because: org.minidns.hla.ResolutionUnsuccessfulException: Asking for _xmpp-client._tcp.192.168.4.162. IN SRV yielded an error response NX_DOMAIN, ‘192.168.4.162:5222’ failed because: org.minidns.hla.ResolutionUnsuccessfulException: Asking for 192.168.4.162. IN A yielded an error response NX_DOMAIN, ‘192.168.4.162:5222’ failed because: org.minidns.hla.ResolutionUnsuccessfulException: Asking for 192.168.4.162. IN AAAA yielded an error response NX_DOMAIN
Also we are able to connect from gajim through any pc on the server .
Also we are not able to connect the localhost instance of server hosted on the same machine .
We are working on it since last week . Still not able to get any success.