title: HttpURLConnection.getInputStream() blocks
body: <p>I'm using the HttpURLConnection class to make http requests.
  My code looks something like this-</p>
  
  <pre><code>while(true){
      try{
           connection=(HttpURLConnection)url.openConnection();
           connection.setDoOutput(true);
           connection.setConnectTimeout(2*1000);
           InputStream in=connection.getInputStream();
      }
      catch(SocketTimeOutException e){}
      catch(IOException e){}
  }
  </code></pre>
  
  <p>I do some processing on the data once I retrieve the InputStream object. My problem is that if  I let the program run long enough, the call to getInputStream blocks and I never get past that.
  <br><br> Am I missing something? Any pointers or help would be greatly appreciated. Thanks.</p>