title: How to resolve "Connect: operation timed out" and "RetryExec" error?
body: <p>My Java program sends one thousand URL to a server and try to fetch result. I started getting this result. How to resolve this?</p>
  
  <p>The code is given in this question    <a href="https://stackoverflow.com/questions/25293196/why-does-the-following-executor-service-java-thread-program-doesnt-shut-down">Why does the following executor service java Thread program doesn&#39;t shut down?</a></p>
  
  <pre><code>   Aug 17, 2014 2:09:40 AM org.apache.http.impl.execchain.RetryExec execute
      INFO: I/O exception (java.net.SocketException) caught when processing request to {}-&gt;MyURL:80: Connection reset
      Aug 17, 2014 2:09:40 AM org.apache.http.impl.execchain.RetryExec execute
      INFO: Retrying request to {}-&gt;MyURL:80
      org.apache.http.conn.HttpHostConnectException: Connect to MyAnotherURL:80 [MyAnotherURL/115.249.106.144] failed: Operation timed out
          at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:140)
          at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:318)
          at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363)
          at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219)
          at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
          at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
          at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
          at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
          at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
          at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
          at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
          at MyProgram$MyRunnable.run(MyProgram.java:224)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
          at java.lang.Thread.run(Thread.java:695)
      Caused by: java.net.ConnectException: Operation timed out
          at java.net.PlainSocketImpl.socketConnect(Native Method)
          at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:382)
          at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:241)
          at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:228)
          at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:431)
          at java.net.Socket.connect(Socket.java:527)
          at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:72)
          at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:123)
          ... 14 more
      Aug 17, 2014 2:10:14 AM org.apache.http.impl.execchain.RetryExec execute
      INFO: I/O exception (java.net.SocketException) caught when processing request to {}-&gt;MyURL:80: Connection reset
      Exception in thread "pool-1-thread-302" java.lang.NullPointerException
          at MyProgram$MyRunnable.run(MyProgram.java:243)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
          at java.lang.Thread.run(Thread.java:695)
      Aug 17, 2014 2:10:14 AM org.apache.http.impl.execchain.RetryExec execute
      INFO: Retrying request to {}-&gt;MyURL:80
      Aug 17, 2014 2:10:14 AM org.apache.http.impl.execchain.RetryExec execute
      INFO: I/O exception (java.net.SocketException) caught when processing request to {}-&gt;MyURL:80: Connection reset
      Aug 17, 2014 2:10:14 AM org.apache.http.impl.execchain.RetryExec execute
      INFO: Retrying request to {}-&gt;MyURL:80
      Aug 17, 2014 2:10:14 AM org.apache.http.impl.execchain.RetryExec execute
      INFO: I/O exception (java.net.SocketException) caught when processing request to {}-&gt;MyURL:80: Connection reset
      Aug 17, 2014 2:10:14 AM org.apache.http.impl.execchain.RetryExec execute
  </code></pre>