Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
import org.jxmpp.jid.DomainBareJid;
import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.jid.util.JidUtil;
import org.jxmpp.stringprep.XmppStringprepException;

public class chat_try {
public static void main(String args[]) 
{

//DomainBareJid serviceName = JidCreate.bareFrom("test3@192.168.0.103");
//Jid jid= JidCreate.from("test3@192.168.0.103");
//Jid myJid = Jid("","",""); 
//Jid jid= JidCreate.from("xxxxx@winiqo.com");
String var = "sonic@nobody.com";
EntityBareJid jid = JidCreate.entityBareFrom(var);

XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
        .setUsernameAndPassword("test3", "elkill")
        //.setXmppDomain(serviceName)
        .setHost("192.168.0.103")
        .setPort(5222)
        .setDebuggerEnabled(true) // to view what's happening in detail
        .build();

XMPPTCPConnection conn1 = new XMPPTCPConnection(config);
try {
    conn1.connect();
    if(conn1.isConnected()) {
        System.out.println("isConnected");
    }
    conn1.login();

    if(conn1.isAuthenticated()) {
         System.out.println("isAuthenticated");
    }
}
catch (Exception e) {
     System.out.println(e.toString());
}

}}


What I have tried:

This is my code for a simple XMPP user connection configuration using "smack" library.It requires a "XMPPDomain" to work. There's a ".setXmppDomain()" method for setting the domain, it takes a "DomainBareJid" as an argument, my attempts to convert a string to DomainBareJid using all the above libraries are resolving to the same error, "Unhandled exception type XmppStringprepException", help!

Sorry if it's a bad doubt, I'am new to Java coding.:)
Posted
Comments
Richard MacCutchan 27-Apr-18 3:35am    
You need to catch the exception and print its details to see why it occurs.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900