views:

233

answers:

3

Hi,

I am currently developing android XMPP client to communicate with the Tigase server setup locally.Before starting development on Android I am writing a simple java code on PC to test connectivity with XMPP server.My XMPP domain is my pc name "mwbn43-1" and administrator username and passwords are admin and tigase respectively.

Following is the snippet of the code I am using

class Test {

public static void main(String args[])throws Exception
{

System.setProperty("smack.debugEnabled", "true");
XMPPConnection.DEBUG_ENABLED = true;

ConnectionConfiguration config = new ConnectionConfiguration("mwbn43-1", 5222);
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);

XMPPConnection con = new XMPPConnection(config);

// Connect to the server
con.connect();
con.login("admin", "tigase");

Chat chat = con.getChatManager().createChat("aaphadke@mwbn43-1",
    new MessageListener() {       
    public void processMessage(Chat chat, Message message) {
           // Print out any messages we get back to standard out.
           System.out.println("Received message: " + message);
       }
   });
        try {
      chat.sendMessage("Hi!");
  }
  catch (XMPPException e) {
      System.out.println("Error Delivering block");
  }


 String host = con.getHost();
 String user = con.getUser();
 String id = con.getConnectionID();
 int port = con.getPort();
 boolean i = false;
 i = con.isConnected();
 if (i)
 System.out.println("Connected to host " + host + " via port " + port + " connection id is " + id);

 System.out.println("User is " + user);
 con.disconnect();
 }
 }

When I run this code I get following error

 Exception in thread "main" Resource binding not offered by server: 
 at   org.jivesoftware.smack.SASLAuthentication.bindResourceAndEstablishSession(SASLAuthenticatio     n.java:416) at    org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:331)
 at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)
 at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:349)
 at Test.main(Test.java:26)

I found this articles on the same problem but no concrete solution here Could anyone please tell me the solution for this problem.I checked the XMPPConnection.java file in the Smack API and it looks the same as given in the link solution.

Thanks, Ameya

A: 

It would help if you post some data exchange between the client and the server. By the way, what Tigase server do you use? Can other clients (Psi, Adium, etc...) successfully authenticate to this installation?

kobit
I am using Tigase-5.0.0b2135.I have used Psi to connect to the server both using admin and by creating a new user.It is able to connect to the local server successfully.
Ameya Phadke
These are the response I am getting from the server <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='mwbn43-1' id='fdfb1fbe-3bae-4855-b86d-89ca7605737e' version='1.0' xml:lang='en'><stream:features><ver xmlns="urn:xmpp:features:rosterver"/><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism>/iq-register"/><auth xmlns="http://jabber.org/features/></stream:features><proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
Ameya Phadke
Actually the response is very big can't post it the entire message here.If you want I can mail you the response
Ameya Phadke
A: 

I think this is a problem with library, a bug. It does not handle protocol correctly. Before the user is authenticated there is no point of sending resource bind, hence it is not advertised by the server. The client should not complain about it.

kobit
What should I do in order to make it work correctly.I tried the same code with Gtalk server and its working fine with it.So I guess problem is with the set up of the server(Some resource problem).Should I do anything on the server side?
Ameya Phadke
A: 

I found the solution to the problem as given in here

These are the lines I should add before I connect to the server

ConnectionConfiguration config = new ConnectionConfiguration("mwbn43-1", 5222);
config.setSASLAuthenticationEnabled(false);
XMPPConnection xmpp = new XMPPConnection(config);

Thanks for all your help

Ameya Phadke