0

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!

Hiren
  • 772
  • 9
  • 23

5 Answers5

3

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.

Hiren
  • 772
  • 9
  • 23
  • Then please consider upvoting the answers that you found helpful. – Flow Sep 07 '13 at 09:02
  • I had found the solution, not from any of Answers here. I learnt it by self, and replied here, the answer, so that it could be useful to others. – Hiren Mar 14 '14 at 22:27
1
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).

Flow
  • 23,572
  • 15
  • 99
  • 156
  • I've hosted a Tigase XMPP Server locally, for which that is domain name I had used while installing and configuring. The domain name appeared by default which is my machine name on the network. – Hiren Sep 06 '13 at 22:24
  • `ELVES-D463645` is not a valid DNS domain nor is it a valid XMPP ServiceName, which is expected here. – Flow Sep 07 '13 at 09:02
0

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.

Artur Hefczyc
  • 996
  • 7
  • 6
  • Do you think hostname should be "localhost" when I have hosted a Tigase XMPP Server locally. – Hiren Sep 06 '13 at 22:25
0

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);
Browny Lin
  • 2,427
  • 3
  • 28
  • 32
  • Thanks Browny Lin, but I am not able to even reach the server, some configuration issues, but I'll surely try as what you suggested, once I reach the server. BTW, I forgot to mention, that I am using a Tigase XMPP Server, which is hosted locally. Thank you. – Hiren Sep 06 '13 at 22:27
0

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();