Hello,
I have problems with _bulk request throwing Connection reset by peer: socket write error; nested exception is javax.net.ssl.SSLProtocolException.
I've read and know about bulk size and etc... So that's not an issue, because the same exact request works with curl or intelij http client:
PUT {{elastic-search-url}}/_bulk
Authorization: Basic {{username}} {{password}}
Accept: application/json
Content-Type: application/x-ndjson
< input.txt
However if I try using spring boot restTemplate I get the error Connection reset by peer:
HttpEntity<String> requestEntity = new HttpEntity<>(stringBuilder.toString(), getHeaderEntity());
restTemplate.put("ELKurl/_bulk", requestEntity, Object.class);
Header entity have all required authorization and accepts:
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN));
headers.setContentType(MediaType.APPLICATION_JSON);
SSL for restTemplate is disabled:
private CloseableHttpClient createHttpClient() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
return HttpClients
.custom()
.setSSLHostnameVerifier(new NoopHostnameVerifier())
.setSSLContext(createSSLContext())
.build();
}
private SSLContext createSSLContext() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
return new SSLContextBuilder().loadTrustMaterial(null, (TrustStrategy) (arg0, arg1) -> true).build();
}
I don't know what else can cause problems? I also checked logs on ELK server side, but nothing can be found there.
How can curl work and spring boot not?
ELK version 7.17.5