XMPP Server, smack API connectivity

5.6k views Asked by At

I am trying to connect to Tigase Server, implement a client in Java using smack API.

    ConnectionConfiguration config = new ConnectionConfiguration("192.32.104.93", 5222, "ELVES-D463645");
    Connection connection =  new XMPPConnection(config);
    connection.connect();

When code reaches connect. I get following stacktrace.

stream:error (host-unknown)
    at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:214)
    at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
    at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
No response from the server.: 
    at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication.java:73)
    at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:230)
    at org.jivesoftware.smack.Connection.login(Connection.java:366)
    at com.directv.xmpp.client.poc.FirstClient.main(FirstClient.java:20)
XMPPException Occured while connecting to server No response from the server.

Can anyone please help me find, where am I going wrong. Thanks!

5

There are 5 answers

2
Hiren On BEST ANSWER

I found the solution to it.

I was entering the service name and hostname in wrong place.

and because my server is locally hosted. following code stub worked for connection with Tigase Server.

ConnectionConfiguration config = new ConnectionConfiguration("localhost", 5222, "yourdomain");

yourdomain shoulde be the domain name which was entered earlier while installation and configuration of the server.

Thank you all for your help though.

1
Artur Hefczyc On

You did not even reach the Tigase server. The error appears to be related to either configuration of the DNS or to parameters you pass to the Smack library. I do not know Smack API but from the error you attach it looks like you provide incorrect hostname, or at least a hostname which does not have a correct DNS entry. This is fine and you should still be able to connect to the server if you can provide IP address as well.

1
Browny Lin On

Try below, or check your XMPP server Authentication setting

ConnectionConfiguration config = new ConnectionConfiguration(XMPP_HOST, XMPP_PORT);
config.setCompressionEnabled(false);
config.setSASLAuthenticationEnabled(false);
connection = new XMPPConnection(config);
2
Flow On
ConnectionConfiguration config = new ConnectionConfiguration("192.32.104.93", 5222, "ELVES-D463645");

The serviceName, third argument of the ConnectionConfiguration constructor, seems to be wrong. I would expect something like a domain here (example.com).

0
Mbula Mboma Jean gilbert On

Here is a code for Smack 4.3.4

 XMPPTCPConnectionConfiguration conf = XMPPTCPConnectionConfiguration.builder()
                .setHostAddress(InetAddress.getByName(host))
                .setXmppDomain(JidCreate.domainBareFrom(Domain))
                .setUsernameAndPassword("username", "password")
                .setPort(5222) 
                .build();
        AbstractXMPPConnection connection = new XMPPTCPConnection(conf);
        connection.connect();
        connection.login();