# TransportClient client node openning too many tcp connections

**URL:** <https://discuss.elastic.co/t/transportclient-client-node-openning-too-many-tcp-connections/59217>\
**Category:** Elasticsearch\
**Created:** [August 29, 2016, 5:05pm UTC](https://discuss.elastic.co/t/transportclient-client-node-openning-too-many-tcp-connections/59217 "2016-08-29T17:05:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunderb123](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@sunderb123](https://discuss.elastic.co/u/sunderb123)\
**Post date:** [August 29, 2016, 5:05pm UTC](https://discuss.elastic.co/t/transportclient-client-node-openning-too-many-tcp-connections/59217/1 "2016-08-29T17:05:26Z")

</div>

Hi All,

We are using java TransportClient api to connect to elasticsearch cluster. We see a lot of unclosed tcp connections lying open for longer time, is there any connection pool setting that can limit this count?

Thanks  
sunder

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [August 29, 2016, 5:19pm UTC](https://discuss.elastic.co/t/transportclient-client-node-openning-too-many-tcp-connections/59217/2 "2016-08-29T17:19:49Z")

</div>

The transport client is basically a mini elasticsearch node and uses the same pooling the nodes use to communicate with one another which works pretty well in my experience. Do you happen to be making a new TransportClient object very frequently?

---

<div class="post-metadata">

**Author:** ![sunderb123](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@sunderb123](https://discuss.elastic.co/u/sunderb123)\
**Post date:** [August 29, 2016, 6:37pm UTC](https://discuss.elastic.co/t/transportclient-client-node-openning-too-many-tcp-connections/59217/3 "2016-08-29T18:37:35Z")

</div>

Hi Nik,

Thanks for quick response.

No we are making a single TransportClient connection per jvm as an singleton, but we are running 2/3 jvm's per machine.

Thanks  
sunder

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [August 29, 2016, 7:03pm UTC](https://discuss.elastic.co/t/transportclient-client-node-openning-too-many-tcp-connections/59217/4 "2016-08-29T19:03:10Z")

</div>

Multiple JVMs per machine shouldn't cause any trouble.

How many connections is a lot? How are you measuring it?

---

<div class="post-metadata">

**Author:** ![sunderb123](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@sunderb123](https://discuss.elastic.co/u/sunderb123)\
**Post date:** [August 30, 2016, 5:11pm UTC](https://discuss.elastic.co/t/transportclient-client-node-openning-too-many-tcp-connections/59217/5 "2016-08-30T17:11:52Z")

</div>

Hi Nik,

We are checking count of established connection using the following command. Without any activity and just initializing the TransportClient at the startup and letting system rest for 8 hrs. Following is the count (4 jvm's)

netstat -an | grep 9300 | wc -l  
224

With very less activity this count shoots[on one jvm] up to

netstat -anp | grep 9300 |wc -l  
18732

Do you see any issue with settings? Following is the code snippet how we are initializing TransportClient

```
        Settings settings = Settings.settingsBuilder()
                .put("cluster.name", rb.getString("cluster.name")).build();
        TransportClient transportClient =TransportClient.builder().settings(settings).build();
        String transPortAddress = rb.getString("transport.address");
        StringTokenizer st = new StringTokenizer(transPortAddress, ",");
        while (st.hasMoreTokens()) {
            String transPortAddr = st.nextToken();
            logger.debug("transPortAddr ---{}", transPortAddr);
            transportClient = transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(transPortAddr), 9300));
        }

```

The above code is loaded as singleton on JVM startup. We are using the BulkProcessor API to do add/delete documents and search api(on transport client) to do document search

Thanks  
sunder

---

<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:** [July 5, 2017, 10:23pm UTC](https://discuss.elastic.co/t/transportclient-client-node-openning-too-many-tcp-connections/59217/6 "2017-07-05T22:23:57Z")

</div>


