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.
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.
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.
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
Below is code that we are using to call rest api:
RestClient restTemplate = null;
HttpEntity<String> entity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> 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));
}
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.