# TransportClient.builder() hang indefinitely

**URL:** <https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088>\
**Category:** Elasticsearch\
**Created:** [May 26, 2016, 6:17pm UTC](https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088 "2016-05-26T18:17:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gautam\_S\_Thakur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gautam_s_thakur/32/5156_2.png) [@Gautam\_S\_Thakur](https://discuss.elastic.co/u/Gautam_S_Thakur)\
**Post date:** [May 26, 2016, 6:17pm UTC](https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088/1 "2016-05-26T18:17:15Z")

</div>

I am trying to use Java 2.3 client API (ES 2.3 is installed on a Linux RH 7 Machine) to connect to ElasticSearch just a single node configuration. However its stuck at the TransportClient.builder().settings(settings).build(). I waited for 5-10 minutes and nothing happened. No exception was thrown either.

btw, I have installed Marvel and Kibana. and they are running perfect. I can access them remotely also using a web-browser.

Configuration: ES 2.3 installed on Redhat 7. with Java 1.8.  
Client API Java 2.3.3 on Mac OSX

So, in the code below, its prints "here0" but no "here1" or noting beyond and just stays there indefinitely. No exception either

```
org.elasticsearch.common.settings.Settings settings = org.elasticsearch.common.settings.Settings
				.settingsBuilder().put("cluster.name", "map_cluster").build();

		Client client = null;
		try {
			System.out.println("here0");
			client = TransportClient.builder().settings(settings).build()
					.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("mercury"), 9300));
			System.out.println("here1");
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.println("here error");
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("here3");

```

Any ideas, why this happening.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 26, 2016, 6:49pm UTC](https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088/2 "2016-05-26T18:49:40Z")

</div>

Did you set `network.host` on your elasticsearch instance?

---

<div class="post-metadata">

**Author:** ![Gautam\_S\_Thakur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gautam_s_thakur/32/5156_2.png) [@Gautam\_S\_Thakur](https://discuss.elastic.co/u/Gautam_S_Thakur)\
**Post date:** [May 26, 2016, 7:26pm UTC](https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088/3 "2016-05-26T19:26:58Z")

</div>

Yes, I have set it up.

> network.host: mercury

---

<div class="post-metadata">

**Author:** ![Gautam\_S\_Thakur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gautam_s_thakur/32/5156_2.png) [@Gautam\_S\_Thakur](https://discuss.elastic.co/u/Gautam_S_Thakur)\
**Post date:** [May 26, 2016, 7:41pm UTC](https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088/4 "2016-05-26T19:41:21Z")

</div>

btw, I don't think its ES server configuration problem.  
I tried to run my Java code completely offline on my laptop (as in - not connected to internet or neither to network). Still it stuck at the same "here0" and never shows "here1". Wondering, whether its the Client library issue or something related.  
On another note, earlier I have extensively used ES 1.7. And everything runs perfectly through my laptop.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 26, 2016, 8:09pm UTC](https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088/5 "2016-05-26T20:09:01Z")

</div>

I wonder if Mercury is resolved to an IP address instead of using the name...

I'm typically using that

```
this.esClient = TransportClient.builder().build()
                .addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));

```

HTH

---

<div class="post-metadata">

**Author:** ![Gautam\_S\_Thakur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gautam_s_thakur/32/5156_2.png) [@Gautam\_S\_Thakur](https://discuss.elastic.co/u/Gautam_S_Thakur)\
**Post date:** [May 26, 2016, 8:35pm UTC](https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088/6 "2016-05-26T20:35:17Z")

</div>

> [@dadoonet](#):
>
> this.esClient = TransportClient.builder().build()  
> .addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));

Nah!! I replaced with the IP address and its still stuck. I tried to debug, and this is where the program got to the last point. (This is Thread.class)

 ![](https://us1.discourse-cdn.com/elastic/original/2X/5/502e81f6e051054c839feaa66a2d2cc26a1ea995.png)

Again, nothing is showing (NO Exception on the output console)

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [May 27, 2016, 1:31am UTC](https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088/7 "2016-05-27T01:31:58Z")

</div>

Hi.

Does it work when you access to elasticsearch from elasticsearch server?

> client = TransportClient.builder().settings(settings).build()  
> .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300));

If it works, I assume its more on the platform related issue.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 27, 2016, 7:01am UTC](https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088/8 "2016-05-27T07:01:53Z")

</div>

Are you able from your client machine to run a REST call like `GET /` for instance?

---

<div class="post-metadata">

**Author:** ![Gautam\_S\_Thakur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gautam_s_thakur/32/5156_2.png) [@Gautam\_S\_Thakur](https://discuss.elastic.co/u/Gautam_S_Thakur)\
**Post date:** [May 27, 2016, 2:42pm UTC](https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088/9 "2016-05-27T14:42:41Z")

</div>

Yes, everything works from my client machine. curl etc. from command prompt. Thats how I figured out, something in my code thats not working properly. But it was hard to debug, as it didn't throw any exception.

Well, I was able to fix the issue. I think it was some kind of version conflict with Spring IO, ES, and Java 1.8. I still don't know the reason btw. I started with a "clean slate" for ES 2.3.3 (instead of porting my old code that was perfectly running ES 1.7) and one by one added the necessary entries in pom.xml.

Current working configuration is Spring IO 4.2.6. RELEASE with Java 1.8 and ES 2.3.3

Now I am able to use the same aforementioned code and inject data in ES.

thank you very much for your support in resolving the issue.

---

<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:48pm UTC](https://discuss.elastic.co/t/transportclient-builder-hang-indefinitely/51088/10 "2017-07-05T22:48:27Z")

</div>


