title: SocketException connection reset exception
body: <p>I am trying to do a get request on an URL. When I hit the URL in a web browser it normally takes around 2 mins to load.</p>
  
  <p>When I am trying to call it from Java - I get a SocketException connection reset error.</p>
  
  <pre><code>Error: java.net.SocketException: Connection reset
      at java.net.SocketInputStream.read(SocketInputStream.java:210)
      at java.net.SocketInputStream.read(SocketInputStream.java:141)
      at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
      at sun.security.ssl.InputRecord.read(InputRecord.java:503)
      at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
      at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940)
      at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
      at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
      at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:735)
      at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
      at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:706)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1569)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
      at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
  </code></pre>
  
  <p>I am trying to do a getResponseCode, I am getting the same error when I am trying to read from the stream as well. </p>
  
  <p>How do I resolve this?</p>
  
  <p>I tried setting the connection timeout and read timeout to 5 mins. None of them worked.</p>
  
  <p>Edit: [Adding code] The following is the code, I am getting the same error while doing a getResponseCode and reading the stream using getInputStream.    </p>
  
  <pre><code>        HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection();
          connection.setRequestMethod("GET");
          connection.setConnectTimeout(TIMEOUT); //5 mins
          connection.setReadTimeout(TIMEOUT); //5 mins
          connection.getResponseCode();
          IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);
  </code></pre>
  
  <p>I don't think this is a server issue because I am able to do a get with other params which would usually load in 15-30 secs in the browser. Only this particular request is failing. (this request takes 2 mins to load in the browser) </p>