AnsweredAssumed Answered

Smack 4.1 Connection Handshake Error

Question asked by Flameater Flameater on Jul 17, 2015
Latest reply on Jul 19, 2015 by Flameater Flameater

Hi,

 

I am using Smack 4.1 to connect to a standard installation of OpenFire 3.10.2.

 

When the application calls the XMPPTCPConnection.connect method, it encounters a Handshake Failed error.

 

How do I determine the right SASL and builder setting for handshaking with the standard, unmodified installation of OpenFire 3.10.2?

 

Source code and error log is provided below.

 

Thank you in advance.

 

These codes show my settings -

 

   public String call() {

   //Context context = getApplicationContext();
  //SmackAndroid.init(context);

   XMPPTCPConnectionConfiguration.Builder connconfig = XMPPTCPConnectionConfiguration.builder();
   connconfig.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

  connconfig.setUsernameAndPassword(strUserId + "@" + strServer, strPassword);

  connconfig.setServiceName(strServer);

  connconfig.setHost(strServer);

  connconfig.setPort(XMPP_DEFAULT_PORT);

  connconfig.setDebuggerEnabled(true);

  connconfig.setSocketFactory(SSLSocketFactory.getDefault());

 

  XMPPTCPConnection connection = new XMPPTCPConnection(connconfig.build());

 

   try {

   retStr = "Starting";

  connection.connect();

   retStr = retStr + ". Connection succeeded to " + connection.getHost();

  connection.login();

   retStr = retStr + ". Logged in to " + connection.getHost();

  connection.disconnect();

   retStr=retStr + ". Disconnected.";

  } catch (org.jivesoftware.smack.SmackException | XMPPException | java.io.IOException e) {

  e.printStackTrace();

   retStr = retStr + e.getMessage();

  }

 

   return retStr;

 

  }

}

 

Error log showing handshake error -

07-17 17:07:15.778  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ javax.net.ssl.SSLHandshakeException: Handshake failed

07-17 17:07:15.779  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.ja va:390)

07-17 17:07:15.780  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.waitForHandshake(OpenSSLSocketImpl. java:623)

07-17 17:07:15.780  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.ja va:585)

07-17 17:07:15.780  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.initReaderAndWriter(XMPPTCPConnect ion.java:642)

07-17 17:07:15.780  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.initConnection(XMPPTCPConnection.j ava:612)

07-17 17:07:15.787  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:834)

07-17 17:07:15.787  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.ja va:360)

07-17 17:07:15.787  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at com.flameaters.boombox.boomboxap.DoThread.call(MainActivity.java:178)

07-17 17:07:15.787  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at com.flameaters.boombox.boomboxap.DoThread.call(MainActivity.java:146)

07-17 17:07:15.788  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)

07-17 17:07:15.788  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

07-17 17:07:15.788  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

07-17 17:07:15.788  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at java.lang.Thread.run(Thread.java:818)

07-17 17:07:15.789  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb4885800: Failure in SSL library, usually a protocol error

07-17 17:07:15.789  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:795 0xae7afb79:0x00000000)

07-17 17:07:15.798  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)

07-17 17:07:15.798  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.ja va:318)

07-17 17:07:15.798  21715-23195/com.flameaters.boombox.boomboxap W/System.err﹕ ... 12 more

Outcomes