0

In My application i am calling the web service method but it takes more time for the response.

Because of without time specifying, i got the following Exception. How to handle it. java.net.socketException: connection Reset.

So i want to implement the timeout for that particular web service method. It means suppose web service response not get after the specified time then it will generate timeout exception. how to implement it.

can anybody help me?

thanks

naresh
  • 10,332
  • 25
  • 81
  • 124
  • possible duplicate of [How to set HttpResponse timeout for Android in Java](http://stackoverflow.com/questions/693997/how-to-set-httpresponse-timeout-for-android-in-java). Gee, that sidebar sure is useful. – Matt Ball Jul 20 '11 at 13:05
  • where i have to put this code? In web service method or any other – naresh Jul 20 '11 at 13:14

1 Answers1

0
URL URLObj = null;
HttpURLConnection ConnObj = null;
URLObj = new URL("Http://Url.to.the/webservice");
ConnObj = (HttpURLConnection) URLObj .openConnection();
ConnObj .setConnectTimeout(5000); // This will set the desired time out for the connection request
Vinayak Bevinakatti
  • 40,205
  • 25
  • 108
  • 139
  • This placed the after calling the web service method. Instead of "Http://Url.to.the/webservice" i am putting the my web service url.is it correct? – naresh Jul 20 '11 at 13:20