Connected but not able to login

My openfire server is up and running. I’ve tested it using Pidgin and Spark.

I can’t connect using Smack for Android though. I’m attaching my connect function below, first I get the keystore and set the TrustManager for my connection. Then, I make a connection configuration and try to connect to my server. I’m always able to CONNECT to the server. The problem is in the “conn2.login()” function. I don’t receive an answer, I get the exception:

org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 10000ms (~10s). Used filter: No filter used or filter was ‘null’.

I tried to change the timeout but it doesn’t matter I’m NEVER able to connect. Just to let you know, I’m using the exactly same configuration on Pidgin, Spark and Android. Same server, same port, same login, same password…

public void connect2() {

final ProgressDialog dialog = ProgressDialog.show(this, “Connecting…”, “Please wait…”, false);
Thread t = new Thread(new Runnable() {

@Override
public void run() {

InputStream ins = getApplicationContext().getResources().openRawResource(R.raw.keystore);
KeyStore ks = null;
try {

ks = KeyStore.getInstance(“BKS”);
ks.load(ins, “123456”.toCharArray());
Log.e(“XMPPChatDemoActivity”, “try ks” + ks.toString());
} catch (Exception e) {

Log.e(“XMPPChatDemoActivity”, e.toString());
}

TrustManagerFactory tmf = null;
try {

tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ks);
Log.e(“XMPPChatDemoActivity”, “try tmf” + tmf.toString());
} catch (Exception e) {

Log.e(“XMPPChatDemoActivity”, e.toString());
}

SSLContext sslctx = null;
try {

sslctx = SSLContext.getInstance(“TLS”);
sslctx.init(null, tmf.getTrustManagers(), null);
Log.e(“XMPPChatDemoActivity”, “try ssl” + sslctx.toString());
} catch (Exception e) {

Log.e(“XMPPChatDemoActivity”, e.toString());
}

// Create a connection to the jabber.org server on a specific port.

XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
config.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
config.setUsernameAndPassword(“abc”, “123456”);
config.setServiceName(SERVERNAME);
config.setHost(SERVERNAME);
config.setResource(“Android”);
config.setPort(5225);
config.setCustomSSLContext(sslctx);
config.setHostnameVerifier(new HostnameVerifier() {

@Override
public boolean verify(String hostname, SSLSession session) {

return true;
}

});

conn2 = new XMPPTCPConnection(config.build());
try {

conn2.connect();
Log.e(“XMPPChatDemoActivity”, "[SettingsDialog] Connected to "+conn2.getHost());
} catch (Exception ex) {

Log.e(“XMPPChatDemoActivity”, "[SettingsDialog] Failed to connect to "+ conn2.getHost());
Log.e(“XMPPChatDemoActivity”, ex.toString());
}

try {

conn2.setPacketReplyTimeout(10000);
conn2.login(“abc”, “123456”);
Log.i(“XMPPChatDemoActivity”, “Logged in as” + conn2.getUser());

// Set the status to available
Presence presence = new Presence(Presence.Type.available);
conn2.sendStanza(presence);
} catch (Exception ex) {

Log.e(“XMPPChatDemoActivity”, "Failed to log in as "+ “a”);
Log.e(“XMPPChatDemoActivity”, ex.toString());
}

dialog.dismiss();
}

});
t.start();
dialog.show();
}