Smack API gives error when logging in to Tigase Server locally

I am currently developing an Android XMPP client to communicate with setting up a Tigase server. Before starting development on Android, I write simple Java code on a PC to check the connection to the XMPP server. My XMPP domain is my name for the PC "mwbn43-1", and the administrator name and password are admin and tigase, respectively.

Below is the code snippet that 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 the 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 these articles on the same problem, but no specific solution here. Can someone please tell me a solution to this problem. I checked the XMPPConnection.java file in the Smack API and looked the same as indicated in the link solution.

Thanks Ameya

+1
2

,

, ,

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

+3

, , . . , , . .

-1

Source: https://habr.com/ru/post/1749634/


All Articles