Hostname verification of certificate failed. Certificate does not authenticate localhost (Re-connection Problem)

Hi,
Can anybody please help on this ?

I am using Smack Version 4.1.7.I have recently enabled Xmpp security its working fine at the time of login but when I disconnect internet from my mobile device and then on internet again then Xmpp connection not established again following error exception occurred.Also i have set domain name in host and in service name.

Note: I am using PLAIN Auth Autorization policy for security

SASLAuthentication.blacklistSASLMechanism(“SCRAM-SHA-1”);
SASLAuthentication.blacklistSASLMechanism(“DIGEST-MD5”);
SASLAuthentication.unBlacklistSASLMechanism(“PLAIN”);

XMPPTCPConnectionConfiguration.Builder configBuilder =
XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword(userName, passWord);
configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
configBuilder.setServiceName(SERVER_NAME);//SERVER_NAME is my domain name
configBuilder.setHost(SERVER_NAME);
configBuilder.setPort(5225);

Technology Used :Java Android

Exception :
System.err: org.jivesoftware.smack.SmackException: java.security.cert.CertificateException: Hostname verification of certificate failed. Certificate does not authenticate localhost
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1025)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:952)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:967)
at java.lang.Thread.run(Thread.java:776)
08-08 14:51:27.964 32178-1587/com.webgreeter.livechat.dev W/System.err: Caused by: java.security.cert.CertificateException: Hostname verification of certificate failed. Certificate does not authenticate localhost
08-08 14:51:27.965 32178-1587/com.webgreeter.livechat.dev W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:771)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:140)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1018)
… 3 more
08-08 14:51:27.965 32178-3334/com.webgreeter.livechat.dev W/AbstractXMPPConnection: Connection closed with error
java.security.cert.CertificateException: Hostname verification of certificate failed. Certificate does not authenticate localhost
at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:771)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:140)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1018)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:952)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:967)
at java.lang.Thread.run(Thread.java:776)
08-08 14:51:27.965 32178-3334/com.webgreeter.livechat.dev W/XmppManager: Connection Closed On Error! Hostname verification of certificate failed. Certificate does not authenticate localhost
08-08 14:51:27.965 32178-3334/com.webgreeter.livechat.dev W/System.err: java.security.cert.CertificateException: Hostname verification of certificate failed. Certificate does not authenticate localhost
at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:771)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:140)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1018)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:952)
08-08 14:51:27.966 32178-3334/com.webgreeter.livechat.dev W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:967)
at java.lang.Thread.run(Thread.java:776)