I'm trying to connect to Gtalk from my Android app using Smack 4.1, but everytime I tried to connect, it shows error : javax.net.ssl.SSLHandshakeException: Handshake failed
Below is my code :
private class ConnectionThread extends AsyncTask<Void, Void, Boolean> {
@Override
protected Boolean doInBackground(Void... params) {
boolean isConnected = false;
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration
.builder();
config.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
config.setUsernameAndPassword(username,password);
config.setServiceName(service);
config.setHost(host);
config.setPort(port);
config.setDebuggerEnabled(true);
//config.setCompressionEnabled(false);
config.setSocketFactory(SSLSocketFactory.getDefault());
connection = new XMPPTCPConnection(config.build());
XMPPConnectionListener connectionListener = new XMPPConnectionListener();
connection.addConnectionListener(connectionListener);
try {
connection.connect();
isConnected = true;
} catch (Exception e) {
Log.e(TAG,"Unable to connect to server = " + e.toString());
}
return isConnected;
}
}
Where host,username, password service and port coming from String.xml values :
<?xml version="1.0" encoding="utf-8"?>
<string name="app_name">XmppLab</string>
<string name="action_settings">Settings</string>
<string name="connect">Connect</string>
<string name="host">talk.google.com</string>
<string name="port">5222</string>
<string name="username">[email protected]</string>
<string name="password">password</string>
<string name="service">gmail.com</string>
Kindly advise do I missed something here? And really appreciate for any kind help.
config.setSocketFactory(SSLSocketFactory.getDefault());
Why? – FlowExceptionInInitializeError
when i try to initializeXMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration .builder();
is this behaviour known ?? – Sharp Edge