service taking long time
Posted on 2013-11-13
I am calling a service through the following code :
obj = new URL(url)
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
BufferedReader in = new BufferedReader(
Here what i did is i gave a wrong url which takes some time to error out.
Finding that in such a case of a wrong url my code will be unneccesarrily stuck.
I added the following :
Before the con.getInputStream() line
Now when i was checking on my local machine the con.getInputStream() line
threw an exception if taking more than a minute.
But when i deployed the code on a remote linux machine
The con.getInputStream() line took more than 3 minutes to error out.
Even though i have specified the timout of 1 minute. I am unable to understand why on remote machine its taking long time and why on my local machine the same code is behaving differently.
If i type the url directly on my browser it takes 20 seconds to error out showing :
The connection has timed out...
Thanks & Regards