1
votes

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 ?

2
Always post the full stacktrace of exceptions. Also set SmackConfiguration.DEBUG to true and show us the output.Flow
@Flow i posted the answer below found here : community.igniterealtime.org/message/240285#240285user987760
@Flow Thanks for your many helps !!! :) i have read many of your posts and comments :)user987760

2 Answers

2
votes

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);
0
votes

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();
}