# java.net.SocketException: Connection reset

**URL:** <https://discuss.elastic.co/t/java-net-socketexception-connection-reset/85293>\
**Category:** Elasticsearch\
**Created:** [May 10, 2017, 5:40pm UTC](https://discuss.elastic.co/t/java-net-socketexception-connection-reset/85293 "2017-05-10T17:40:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arul\_since1975](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@arul\_since1975](https://discuss.elastic.co/u/arul_since1975)\
**Post date:** [May 10, 2017, 5:40pm UTC](https://discuss.elastic.co/t/java-net-socketexception-connection-reset/85293/1 "2017-05-10T17:40:14Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 7, 2017, 5:51pm UTC](https://discuss.elastic.co/t/java-net-socketexception-connection-reset/85293/2 "2017-06-07T17:51:53Z")

</div>

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