java.net.SocketException: Connection reset

I am running into Connection Reset Exception. I was trying to send BULK Ingest containing 2110 documents in it and total size of message is 760KB. This message is sent to ElasticSearch through Kafka producer consumer model. Following piece of code is from where consumer sends the message to ES.

public CloseableHttpResponse getHttpResponseForPOSTRequest(final String resourceUrl, final String content,
        final ContentType contentType, final Map<String, String> headers)
        throws ClientProtocolException, IOException {

    HttpPost httpPost = new HttpPost(this.httpHost + resourceUrl);

    this.basicAuthHeader.ifPresent(basicAuth -> httpPost.addHeader(basicAuth));

    Optional.ofNullable(headers)
            .ifPresent(value -> value.forEach((k, v) -> httpPost.addHeader(k, v)));

    if (StringUtils.isNotEmpty(content)) {
        httpPost.setEntity(new StringEntity(content, contentType));
    }

    return httpClient.execute(httpPost);

}

I ran into following exception.

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:961)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:918)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
at com.trgr.elasticsearch.plugin.kafkaesque.es.ElasticsearchRestClient.getHttpResponseForPOSTRequest(ElasticsearchRestClient.java:199)
at com.trgr.elasticsearch.plugin.kafkaesque.es.ElasticsearchRestClient.getHttpResponseForPOSTRequest(ElasticsearchRestClient.java:180)
at com.trgr.elasticsearch.plugin.kafkaesque.es.ElasticsearchRestClient.processKafkaMessage(ElasticsearchRestClient.java:111)

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.