Users Pricing

forum

Home Forums Connection Timeout in URLConnection using java? – MindStick

Connection Timeout in URLConnection using java?

Kate Smith 2586 05 Oct 2013

In the below line of code to get the data from web service. But its behavior is unexpected. Its return the data 7 to 8 times when I hit through code, but after that connection timeout error. Any Solution??

URL url = new URL(webPage);  

URLConnection urlConnection = url.openConnection();
System.out.println("Connection Timeout ===== "+urlConnection.getConnectTimeout());
urlConnection.setRequestProperty("Authorization", "Basic " + authStringEnc);
urlConnection.setConnectTimeout(20000);
InputStream is = urlConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is); 


It is return the Exception : java.net.SocketTimeoutException: connect timed


out


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md