1

I am using asmack-android-8-source-4.0.6

when i try to connect to the server whether it is openFire or Ejabbered i get this exception

org.jivesoftware.smack.SmackException$NoResponseException

here's my code:

        SmackAndroid.init(getApplicationContext());
        ConnectionConfiguration conConfig = new ConnectionConfiguration(HOST, PORT);
        conConfig.setDebuggerEnabled(true);

        connection = new XMPPTCPConnection(conConfig);
        try {
            connection.connect();
            Log.i("AppName", "CONNECTED TO " + connection.getHost());
        }

when i call

connection.connect();

i get this exception :

org.jivesoftware.smack.SmackException$NoResponseException

note the i have tried the same code on asmack-android-19-0.8.10 and it works perfectly

i guess the issue is with the

XMPPTCPConnection

because in the asmack-android-19-0.8.10 i use

XMPPConnection

any help ?

user987760
  • 1,061
  • 3
  • 12
  • 26
  • Always post the full stacktrace of exceptions. Also set SmackConfiguration.DEBUG to true and show us the output. – Flow Jan 15 '15 at 10:59
  • @Flow i posted the answer below found here : https://community.igniterealtime.org/message/240285#240285 – user987760 Jan 15 '15 at 11:08
  • @Flow Thanks for your many helps !!! :) i have read many of your posts and comments :) – user987760 Jan 15 '15 at 11:08

2 Answers2

2

I have found the problem all i did is adding this line:

ConnectionConfiguration.setSecurityMode(SecurityMode.disabled);

and i was connected to server successfully

here's my configuration in the end :

ConnectionConfiguration ConnectionConfiguration =  new ConnectionConfiguration(HOST, PORT);
ConnectionConfiguration.setDebuggerEnabled(true);
ConnectionConfiguration.setSecurityMode(SecurityMode.disabled);
user987760
  • 1,061
  • 3
  • 12
  • 26
  • I am facing the same problem. I disabled security mode also and I am using this [code](http://paste.ofcode.org/36CSHhtnaEVDUrgqnWMzqW7) to connect to xmpp and i am getting [exception](http://paste.ofcode.org/3b9wT5yeuLB97rfZgZ7eFEZ), can you tell any solution for this? – nawaab saab Jan 16 '15 at 07:04
  • what is the exception your getting ? – user987760 Jan 22 '15 at 16:32
  • @user987760 have you worked on file sharing using xmpp and asmack. If yes, then kindly help in solving this [issue](http://stackoverflow.com/q/28271210/4358880) – Android Rockss Feb 02 '15 at 06:46
  • @AndroidRockss i did not user the xmpp file sharing, instead i'm using http for uploading/downloading Media and i send the urls through custom PackageExtention – user987760 Feb 03 '15 at 09:04
0

try this:

public void connect() 
{

    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            SmackAndroid.init(getApplicationContext());

            ConnectionConfiguration conConfig = new ConnectionConfiguration(HOST, PORT);
            conConfig.setDebuggerEnabled(true);
            conConfig.setSecurityMode(SecurityMode.disabled);
            connection = new XMPPTCPConnection(conConfig);
            try {
                connection.connect();
                connection.login("unm", "pswd");
                Presence presence = new Presence(Presence.Type.available);
                connection.sendPacket(presence);
                setConnection(connection);

            } catch (XMPPException e) {
                e.printStackTrace();
            } catch (SmackException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
    t.start();
}
Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58
Kinjal
  • 1,195
  • 4
  • 13
  • 24