Issue while login in openfire using BOSHConnection (asmack-android-7.jar library)

I am trying to make a BOSHConnection to openfire (using asmack-android-7.jar library). Following is the code -

BOSHConfiguration = new BOSHConfiguration(true, “localhost”, 7070, “/http-bind/”, “domain_name”);

config.setNotMatchingDomainCheckEnabled(false);

config.setVerifyChainEnabled(false);

config.setVerifyRootCAEnabled(false);

config.setCustomSSLContext(getSSLContext());

BOSHConnection conn = new BOSHConnection(config);

try {

conn.connect();

}

catch (XMPPException xe)

{

Log.log(Log.ERROR,"Error while conncting : " + xe.getMessage());
throw new Exception(xe.getMessage());

}

String resource = “RES-” + System.currentTimeMillis();

SASLAuthentication.supportSASLMechanism(“PLAIN”, 0);

try {

conn.login(username, password, resource);
result = new HashMap();
result.put(“session ID”, conn.getConnectionID());
result.put(“user ID”, conn.getUser());
result.put(“last RID”, Long.toString(conn.getLastRID()));
result.put(“route ID”, conn.getRouteId());
result.put(“XMPPBOSHUrlPart”, “/http-bind/”);
conn.disconnectLocally();
}
catch (XMPPException e) {
Log.log(Log.ERROR,"Error while login : " + e.getMessage());
}

The code works properly but sometimes i get follying error -

Error while login : No response from the server.

I check the openfire log and it authenticate successfully from AuthProvider and there were no other errors in openfire logs.

Can some please tell what could be the cause of this issue and how can we resolve this.

Thanks.