powered by Jive Software

Server connection error through ejabberd


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 : .
Domain: .
JID Format: <user@>

Here is My Code snippet:

img_continue.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Log.d(LOGTAG,“User clicked on login”);
Runnable runnable=new Runnable() {
public void run() {

                    InetAddress addr = null;
                    try {
                        addr = InetAddress.getByName(""); 
                    } catch (UnknownHostException e) {
                    HostnameVerifier verifier = new HostnameVerifier() {
                        public boolean verify(String hostname, SSLSession session) {
                            return false;
                    XMPPTCPConnectionConfiguration connectionConfiguration = null;
                        connectionConfiguration = XMPPTCPConnectionConfiguration.builder()
                                .setUsernameAndPassword("alice", "9009")
                    }catch (XmppStringprepException e){

                    AbstractXMPPConnection connection = null;
                    connection = new XMPPTCPConnection(connectionConfiguration);
                    connection.addConnectionListener(new ConnectionListener() {
                        public void connected(final XMPPConnection connection) {
                            Log.d(LOGTAG,"chat Application- connected");

                        public void authenticated(XMPPConnection connection, boolean resumed) {
                            Log.d(LOGTAG,"chat Application-authenticated");

                        public void connectionClosed() {
                            Log.d(LOGTAG,"chat Application- closed");

                        public void connectionClosedOnError(Exception e) {
                            Log.d(LOGTAG,"chat Application- connectionClosedOnError");
                    ChatManager chatManager= ChatManager.getInstanceFor(connection);
                    chatManager.addIncomingListener(new IncomingChatMessageListener() {
                        public void newIncomingMessage(EntityBareJid from, Message message, Chat chat) {
                            Log.d(LOGTAG,"Incoming message :" +message.getBody());
                    try {
                    } catch (XMPPException e) {
                    } catch (SmackException e) {
                    } catch (IOException e) {
                    } catch (InterruptedException e) {

            Thread connectionThread = new Thread(runnable);


It is causing this error continuously

  • Could not resolve DNS SRV resource records for _xmpp-client._tcp. Consider adding those.

  • SmackException$ConnectionException: The following addresses failed: ‘_xmpp-client._tcp.’ failed because: org.minidns.hla.ResolutionUnsuccessfulException: Asking for _xmpp-client._tcp. IN SRV yielded an error response NX_DOMAIN, ‘’ failed because: org.minidns.hla.ResolutionUnsuccessfulException: Asking for IN A yielded an error response NX_DOMAIN, ‘’ failed because: org.minidns.hla.ResolutionUnsuccessfulException: Asking for 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.

Please Help!!!

I’d strongly advice you to set up a proper DNS name for your server. Using bare IP addresses is considered bad practice.

Try using setHost("") instead of setHostName.
Also, but probably unrelated: Why does your verifier always return false?

I think with Smack 4.3.1, he wants to use setHostAddress(InetAddress).

Even if we connect to the server on the same machine whose domain name is set as the “localhost”. It is returning the same response.

Did you use setHostAddress(), if so, with which IP?

we did it the

output of the line

is coming: /
Doesn’t it supposed to be “localhost”?

also using setHostAddress(“”);

I am encountering this error:
2019-08-26 06:51:19.673 11834-11920/com.example.txtxtalk W/System.err: org.jivesoftware.smack.SmackException$ConnectionException: The following addresses failed: ‘’ failed because: / exception: java.net.ConnectException: failed to connect to / (port 5222) from / (port 43458) after 30000ms: isConnected failed: ECONNREFUSED (Connection refused)

Please help

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.