I have a code where I am using http post which works fine but sometimes it get stuck at http.execute and did not go ahead as it waits for response. So what can be done in such case?
I am not getting any error that says cannot connect or something like that. It just gets stucked there.
Here is my code
HttpClient client = new DefaultHttpClient();
HandleWebserviceCallPojo pojo = getpojo(sessionId);
String url = "http:x.y.z:8080//"; // my url
logger.info("------------------------------------------------------------");
logger.info("Sending response to client's url..");
logger.info("url-->" + url);
HttpPost post = new HttpPost(url.trim());
post.setEntity(new UrlEncodedFormEntity(urlParameters));
HttpResponse response = client.execute(post);
//the code gets stucked at client.execute and there is no way out after that
logger.info("------------------------------------------------------------");
logger.info("response" + response);
So is it possible to timeout that statement after some time so that code can move ahead?