title: java.net.SocketException: Broken pipe (Write failed) while posting json payload to rest api
body: <p>Getting java.net.SocketException: Broken pipe (Write failed) while sending json payload arround size of 3.2 mb in size but its intermittent. However for small size it's working. The code is running on jetty server.</p>
  
  <p>I thought there may be memory issue after upgrading server memory with heap size arround 7GB and verified while running this job memory and cpu utilization was normal but still it is failing.</p>
  
  <p>Also we try with modifying below sysctl setting on jetty server but still no luck sometimes get processed successfully but from few days it continously failing.</p>
  
  <pre><code>   sysctl -w net.core.rmem_max=16777216  sysctl -w
     net.core.wmem_max=16777216  sysctl -w net.ipv4.tcp_rmem="4096 87380
     16777216"  sysctl -w net.ipv4.tcp_wmem="4096 16384 16777216"   sysctl
     -w net.core.somaxconn=4096   sysctl -w net.core.netdev_max_backlog=16384  sysctl -w net.ipv4.tcp_max_syn_backlog=8192 
  </code></pre>
  
  <p>Below is code that we are using to call rest api:</p>
  
  <pre><code>   RestClient restTemplate = null;
     HttpEntity&lt;String&gt; entity = new HttpEntity&lt;String&gt;(payload, headers);
     ResponseEntity&lt;String&gt; responseEntity = null;try
      {
          restTemplate = new RestClient(null, null, accessKey, secretKey);
          responseEntity = restTemplate.exchange(url, method, entity, String.class);
          return responseEntity;
      }catch(
      Exception ex)
      {
  
      }
  
      // contructor setting
      public RestClient(final String proxyHost, final String proxyPort, final String username, final String password) {
          CredentialsProvider credsProvider = new BasicCredentialsProvider();
          credsProvider.setCredentials(new AuthScope(null, -1), new UsernamePasswordCredentials(username, password));
          HttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
          setRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient));
      }
  </code></pre>
  
  <p>Any idea how i can fix this issue, i am struggling past more than 20 days. Please let me know if you need any more input.</p>