1
votes

I have openfire installed on remote server. I can connect to it using the Spark XMPP client. But I am getting connection error when I use my Android XMPP client. Here is the connection code part of the Android client application:

// Create a connection
    String serverIp = "14.63.XXX.XXX";
    ConnectionConfiguration connConfig =
            new ConnectionConfiguration(serverIp, 5222);
    connConfig.setSASLAuthenticationEnabled(true);
    XMPPConnection connection = new XMPPConnection(connConfig);


    try {
        connection.connect();
        Log.i("XMPPClient", "Connected to " + connection.getHost());
    } catch (XMPPException ex) {
        Log.e("XMPPClient", "Failed to connect to " + connection.getHost());
        Log.e("XMPPClient", ex.toString());
        xmppClient.setConnection(null);
    }
    try {
        connection.login(username, password);
         .......

I am getting error when connection.connect(); is executed. I checked the port at the server and its open. I also tried 5223 port. I checked the permission on XMPP client also. I googled it and couldn't find a solution that fix this problem. Can anybody please suggest me what to do?

1
have you check all necessary information for it??Piyush
You missed an important piece of information: what error are you getting? :)MattJ
@PiyushGupta I have checked everything. Also I tried different possible ways. I even tried the XMPP sample from javaprogrammingforums.com/java-networking-tutorials/… and it works with my server. But when I use the same class with the android (by removing MessageListener Implementation), still doesn't work. Now the error becomes when ConnectionConfiguration is created!!!Mati Bekuma
@MattJ I don't exactly get the error because on eclipse it says Source not found. P.s see my above comment also. ThanksMati Bekuma

1 Answers

2
votes

Found temporary solution :).. I put the connection part of the code in AsyncTask (http://developer.android.com/reference/android/os/AsyncTask.html). Now it works fine but I did other stuffs also, I used the smack API library from another project on the web that is already working.. So Im still searching for smack api that works with my project. I have seen http://asmack.org.. but didn't work for me!!