title: SocketException: Connection reset - Client Jersey 2.0 Java 7
body: <p>I'm getting similar error to this <a href="https://stackoverflow.com/questions/41741763/connection-reset-on-jersey-with-java-7">link1</a>. 
  When I post(client to server) a small xml via REST, everything works fine. Unfortunately I'm getting an <strong>error</strong> while I'm posting some bigger xmls, when the <strong>connection lasts longer than 10/15 min</strong>. (I assume It's some kind of timeout)</p>
  
  <p>I corrected my SSL certs as it was mentioned in the link1 - configureClient() method is the same in my case as the solution from the one in the link1. </p>
  
  <p>I added also System.setProperty("java.net.preferIPv4Stack" , "true"); - sometimes it solves Connection reset</p>
  
  <p><strong>Essential info:</strong></p>
  
  <p>Error: javax.ws.rs.ProcessingException: java.net.SocketException: Connection reset</p>
  
  <p>Method: REST POST</p>
  
  <p>Java version: 7</p>
  
  <p>Engine: Jersey 2.x</p>
  
  <p>Side: Client</p>
  
  <p>System: Windows 7</p>
  
  <p><strong>My client:</strong></p>
  
  <pre><code>   System.setProperty("java.net.preferIPv4Stack" , "true");
  
  RestMethodes restMethodes = new RestMethodes();
  ClientConfig config = new ClientConfig();
  config = config.property(ClientProperties.CONNECT_TIMEOUT, 0);
  config = config.property(ClientProperties.READ_TIMEOUT, 0);
  
  config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
  
  Client client = configureClient(config);
  client.register(HttpAuthenticationFeature.basic(USER, PASS));
  
  WebTarget target = client.target(SERVER_URL + "/bundles/assets");
  Invocation.Builder responseInvocation = target.request(MediaType.APPLICATION_JSON);
  
  // My exception is thrown there
  
  Response response = responseInvocation.post(Entity.xml(assetsString)); 
  
  String entity = response.readEntity(String.class);
  //entity = jsonPrettyPrinter(entity);
  
  if (entity.isEmpty() || entity.equals("")) {
      log.info("[POST ASSETS] Failed : Response is empty");
  }
  Response.StatusType codeName = response.getStatusInfo();
  int code = response.getStatus();
  
  if (code != 200) {
      log.error("[POST ASSETS] Failed : HTTP error code : " + response.getStatus() + "\n" + entity);
      response.close();
  } else {
      log.info("[POST ASSETS] RESPONSE CODE ID : " + code + " CODE NAME : " + codeName);
      log.info("[POST ASSETS] RESPONSE : " + entity);
      response.close();
  }
  client.close();
  </code></pre>
  
  <p><strong>My ERROR</strong></p>
  
  <pre><code>Exception in thread "main" javax.ws.rs.ProcessingException: java.net.SocketException: Connection reset
  at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:287)
  at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:252)
  at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:684)
  at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:681)
  at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
  at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
  at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
  at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
  at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:681)
  at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:437)
  at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:343)
  at com.sas.spl.saslineagebridges.test.PostTester.main(PostTester.java:61)
  Caused by: java.net.SocketException: Connection reset
  at java.net.SocketInputStream.read(SocketInputStream.java:209)
  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:973)
  at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:930)
  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:704)
  at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)
  at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:675)
  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)
  at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:399)
  at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:285)
  ... 11 more
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I forgot to mention that I managed to post my request via <strong>CURL</strong> from bash with infinity timeout and keep alive, so It shouldn't be the servers issue. The CURL REST post took 24 min. and my java client throws connection reset after 15 min. In my opinion It might be my fault.</p>