title: Apache client closes connection too long (in 1 second)
body: <p>I have simmilar issue as this described in <a href="https://stackoverflow.com/questions/68929051/wiremock-sometimes-it-throws-software-caused-connection-abort-recv-failed">Wiremock - sometimes it throws &quot;Software caused connection abort: recv failed&quot;</a></p>
  <p>that's why I have added header <code>connection: close</code> in my mocked headers:</p>
  <pre><code>var wireMockRule = new WireMockRule(&quot;9999&quot;);
  wireMockRule.stubFor(
      post(&quot;xxxx/myapp&quot;))
              .willReturn(
                          aResponse()
                                  .withHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
                                  .withHeader(&quot;Connection&quot;, &quot;close&quot;)
                                  .withBody(&quot;&quot;&quot;
                                      xxxx
                                      }&quot;&quot;&quot;)
                  )
  );
  </code></pre>
  <p>Then after every response received client will close his connection. This is how I do the posting:</p>
  <pre><code>var restTemplate = new RestTemplate();
  restTemplate.postForEntity(&quot;xxxx/myapp&quot;, ... );
  </code></pre>
  <p>The problem is that Apache Http Client always closes it in 1 seconds. Look at logs:</p>
  <pre><code>23:50:19.993 [myservice2-executor-thread2] DEBUG xxx.DefaultManagedHttpClientConnection - http-outgoing-3: Close connection
  23:50:19.994 [myservice3-executor-thread3] DEBUG xxx.PoolingHttpClientConnectionManager - Connection [id: 2][route: {}-&gt;http://localhost:9999] can be kept alive indefinitely
  23:50:19.994 [myservice3-executor-thread3] DEBUG xxx.DefaultManagedHttpClientConnection - http-outgoing-2: set socket timeout to 0
  23:50:19.994 [myservice3-executor-thread3] DEBUG xxx.PoolingHttpClientConnectionManager - Connection released: [id: 2][route: {}-&gt;http://localhost:9999][total available: 2; route allocated: 2 of 200; total allocated: 2 of 500]
  23:50:20.995 [myservice2-executor-thread2] DEBUG xxx.execchain.MainClientExec - Connection discarded
  23:50:20.995 [myservice2-executor-thread2] DEBUG xxx.PoolingHttpClientConnectionManager - Connection released: [id: 3][route: {}-&gt;http://localhost:9999][total available: 0; route allocated: 0 of 200; total allocated: 0 of 100]
  </code></pre>
  <p>Is there a possibility to configure the Apache Client to do the closing immediately?<br />
  This is my try, but it doesn't solve the problem.</p>
  <pre><code>var connectionManager = new PoolingHttpClientConnectionManager();
          connectionManager.setValidateAfterInactivity(1);
          connectionManager.setDefaultSocketConfig(
              SocketConfig.custom()
                  .setTcpNoDelay(true)
                  .setSoLinger(0)
                  .build()
          );
  
  var httpClient = HttpClientBuilder.create()
          .setConnectionManager(connectionManager)
          .setDefaultRequestConfig(
              RequestConfig.custom()
                  .setExpectContinueEnabled(false)
                  .build()
          )
          .build();
  
  var clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
          clientHttpRequestFactory.setHttpClient(httpClient);
  
  var restTemplate = new RestTemplate(clientHttpRequestFactory)
  </code></pre>