Remote host closed connection during handshake

Hi, When i try to connect XMPP using 5222/5223 port i am getting the following error. Remote host closed connection during handshake

at Source)

at Source)

at Source)

at Source)

at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)

at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)

at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)

at sun.nio.cs.StreamEncoder.flush(Unknown Source)

at Source)

at Source)

at org.jivesoftware.smack.PacketWriter.openStream(

at org.jivesoftware.smack.PacketWriter.writePackets(

at org.jivesoftware.smack.PacketWriter.access$000(

at org.jivesoftware.smack.PacketWriter$

Caused by: SSL peer shut down incorrectly

at Source)

… 14 more

Code :

config = new ConnectionConfiguration(xmppHost,
xmppSecurePort , “”);


config.setSocketFactory(new SSLProtocolSocketFactory());



Could any one suggest me what might be causing this issue?

Note : When i comment config.setSocketFactory(new SSLProtocolSocketFactory()); line of code it works fine with 5222 port and it treated as not secure connection. My requirement is to make the XMPP secure connection.