开发者

Smack API giving error while logging into Tigase Server setup locally

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜