# Cannot connect to elasticsearch via java api

**URL:** <https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-java-api/10795>\
**Category:** Elasticsearch\
**Created:** [February 19, 2013, 9:15am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-java-api/10795 "2013-02-19T09:15:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ulli](https://avatars.discourse-cdn.com/v4/letter/u/f04885/32.png) [@Ulli](https://discuss.elastic.co/u/Ulli)\
**Post date:** [February 19, 2013, 9:15am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-java-api/10795/1 "2013-02-19T09:15:31Z")

</div>

Hi,

I'm trying to connect to a runnung elasticsearch instance via java api:

```
    Settings settings = ImmutableSettings.settingsBuilder().put(

```

"cluster.name", "elasticsearch").put(  
"client.transport.sniff", true).build();  
this.client = new TransportClient(settings).addTransportAddress(new  
InetSocketTransportAddress(  
"localhost", 9300));

But the connection failes:

2013-02-19 10:06:23,983 [INFO][elasticsearch[Nova-Prime][generic][T#2]][elasticsearch.client.transport]  
[Nova-Prime] failed to get local cluster state for  
[#transport#-1][inet[localhost/127.0.0.1:9300]], disconnecting...  
org.elasticsearch.transport.ReceiveTimeoutTransportException: [][inet[  
localhost/127.0.0.1:9300]][cluster/state] request\_id [0] timed out after [  
5000ms]  
at org.elasticsearch.transport.TransportService$TimeoutHandler.run(  
TransportService.java:342)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.  
java:1110)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor  
.java:603)  
at java.lang.Thread.run(Thread.java:722)

In the elasticsearch log I see this exception:

[10:06:19,023][WARN][transport.netty] [master node] exception  
caught on netty layer [[id: 0x8920f463, /127.0.0.1:53785 =\> /127.0.0.1:9300  
]]  
org.elasticsearch.common.netty.handler.codec.frame.TooLongFrameException:transport content length received  
[1gb] exceeded [914.1mb]  
at org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.decode(  
SizeHeaderFrameDecoder.java:31)  
at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.  
callDecode(FrameDecoder.java:422)  
at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.  
messageReceived(FrameDecoder.java:303)  
at org.elasticsearch.common.netty.channel.  
SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.  
java:75)  
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.  
sendUpstream(DefaultChannelPipeline.java:565)  
at org.elasticsearch.common.netty.channel.  
DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(  
DefaultChannelPipeline.java:793)  
at org.elasticsearch.common.netty.OpenChannelsHandler.handleUpstream  
(OpenChannelsHandler.java:74)  
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.  
sendUpstream(DefaultChannelPipeline.java:565)  
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.  
sendUpstream(DefaultChannelPipeline.java:560)  
at org.elasticsearch.common.netty.channel.Channels.  
fireMessageReceived(Channels.java:268)  
at org.elasticsearch.common.netty.channel.Channels.  
fireMessageReceived(Channels.java:255)  
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(  
NioWorker.java:84)  
at org.elasticsearch.common.netty.channel.socket.nio.  
AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:471)  
at org.elasticsearch.common.netty.channel.socket.nio.  
AbstractNioWorker.run(AbstractNioWorker.java:332)  
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(  
NioWorker.java:35)  
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(  
ThreadRenamingRunnable.java:102)  
at org.elasticsearch.common.netty.util.internal.  
DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(  
ThreadPoolExecutor.java:1146)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(  
ThreadPoolExecutor.java:615)

What is going wrong?

Thanks in advance  
Ulli

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [February 19, 2013, 9:32am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-java-api/10795/2 "2013-02-19T09:32:06Z")

</div>

You have set sniff to true, that is, your client may be not connecting  
to the address you have specified as a transport address ("localhost",  
port 9300).

Note, the address the client is connecting to should be the specified  
host in the publish\_host setting in each node.

If you want to connect to a multi node cluster, ensure you can reach  
every node over the network from your transport client.

In a single node devel setup, you may have not assigned the host name in  
/etc/hosts to an IP address. Then you have some options: use 127.0.0.1  
instead of "localhost", add the host name to the line where localhost  
is declared in /etc/hosts (not recommended for hostname-based network  
setups and not always possible), set sniff to false, or write extra code  
to find the host name from java and connect to this address instead of  
"localhost" - usually something with  
InetAddress.getLocalHost().getHostName().

Jörg

Am 19.02.13 10:15, schrieb Ulli:

> Hi,
> 
> I'm trying to connect to a runnung elasticsearch instance via java api:
> 
> |  
> Settingssettings  
> =ImmutableSettings.settingsBuilder().put("cluster.name","elasticsearch").put(  
> "client.transport.sniff",true).build();  
> this.client  
> =newTransportClient(settings).addTransportAddress(newInetSocketTransportAddress(  
> "localhost",9300));
> 
> |
> 
> But the connection failes:
> 
> |  
> 2013-02-1910:06:23,983[INFO][elasticsearch[Nova-Prime][generic][T#2]][elasticsearch.client.transport]  
> [Nova-Prime] failed to get local cluster state for  
> [#transport#-1][inet[localhost/127.0.0.1:9300]], disconnecting...  
> org.elasticsearch.transport.ReceiveTimeoutTransportException:[inet[localhost/127.0.0.1:9300]][cluster/state]request\_id  
> [0]timed outafter [5000ms]  
> at  
> org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:342)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
> at java.lang.Thread.run(Thread.java:722)
> 
> |
> 
> In the elasticsearch log I see this exception:
> 
> |  
> [10:06:19,023][WARN][transport.netty][master node]exception caught  
> on netty layer [[id:0x8920f463,/127.0.0.1:53785 =\> /127.0.0.1:9300]]  
> org.elasticsearch.common.netty.handler.codec.frame.TooLongFrameException:transport  
> content length received [1gb]exceeded [914.1mb]  
> at  
> org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.decode(SizeHeaderFrameDecoder.java:31)  
> at  
> org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:422)  
> at  
> org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)  
> at  
> org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)  
> at  
> org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)  
> at  
> org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:793)  
> at  
> org.elasticsearch.common.netty.OpenChannelsHandler.handleUpstream(OpenChannelsHandler.java:74)  
> at  
> org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)  
> at  
> org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)  
> at  
> org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:268)  
> at  
> org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:255)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:84)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:471)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:332)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:35)  
> at  
> org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)  
> at  
> org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> 
> |
> 
> What is going wrong?
> 
> ## Thanks in advance Ulli
> 
> You received this message because you are subscribed to the Google  
> Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send  
> an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ulli](https://avatars.discourse-cdn.com/v4/letter/u/f04885/32.png) [@Ulli](https://discuss.elastic.co/u/Ulli)\
**Post date:** [February 19, 2013, 11:16am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-java-api/10795/3 "2013-02-19T11:16:30Z")

</div>

Thanks for your reply. I tried it with 127.0.0.1 and sniff to false but it  
didn' change anything. InetAddress.getLocalHost() throws an  
UnknownHostException.  
But actually I think the exception in the elasticsearch log indicates that  
at least something is arivung on elasticsearch side. But what does this  
exception mean?

Am Dienstag, 19. Februar 2013 10:32:06 UTC+1 schrieb Jörg Prante:

> You have set sniff to true, that is, your client may be not connecting  
> to the address you have specified as a transport address ("localhost",  
> port 9300).
> 
> Note, the address the client is connecting to should be the specified  
> host in the publish\_host setting in each node.
> 
> If you want to connect to a multi node cluster, ensure you can reach  
> every node over the network from your transport client.
> 
> In a single node devel setup, you may have not assigned the host name in  
> /etc/hosts to an IP address. Then you have some options: use 127.0.0.1  
> instead of "localhost", add the host name to the line where localhost  
> is declared in /etc/hosts (not recommended for hostname-based network  
> setups and not always possible), set sniff to false, or write extra code  
> to find the host name from java and connect to this address instead of  
> "localhost" - usually something with  
> InetAddress.getLocalHost().getHostName().
> 
> Jörg
> 
> Am 19.02.13 10:15, schrieb Ulli:
> 
> > Hi,
> > 
> > I'm trying to connect to a runnung elasticsearch instance via java api:
> > 
> > |  
> > Settingssettings  
> > =ImmutableSettings.settingsBuilder().put("cluster.name","elasticsearch").put(
> 
> > "client.transport.sniff",true).build();  
> > this.client
> 
> =newTransportClient(settings).addTransportAddress(newInetSocketTransportAddress(
> 
> > "localhost",9300));
> > 
> > |
> > 
> > But the connection failes:
> > 
> > |
> 
> 2013-02-1910:06:23,983[INFO][elasticsearch[Nova-Prime][generic][T#2]][elasticsearch.client.transport]
> 
> > [Nova-Prime] failed to get local cluster state for  
> > [#transport#-1][inet[localhost/127.0.0.1:9300]], disconnecting...
> 
> org.elasticsearch.transport.ReceiveTimeoutTransportException:[inet[localhost/127.0.0.1:9300]][cluster/state]request\_id
> 
> > [0]timed outafter [5000ms]  
> > at
> 
> org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:342)
> 
> > ```
> > at 
> > 
> > ```
> 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> 
> > ```
> > at 
> > 
> > ```
> 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> 
> > ```
> > at java.lang.Thread.run(Thread.java:722) 
> > 
> > ```
> > 
> > |
> > 
> > In the elasticsearch log I see this exception:
> > 
> > |  
> > [10:06:19,023][WARN][transport.netty][master node]exception caught  
> > on netty layer [[id:0x8920f463,/127.0.0.1:53785 =\> /127.0.0.1:9300]]
> 
> org.elasticsearch.common.netty.handler.codec.frame.TooLongFrameException:transport
> 
> > content length received [1gb]exceeded [914.1mb]  
> > at
> 
> org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.decode(SizeHeaderFrameDecoder.java:31)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:422)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:793)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.OpenChannelsHandler.handleUpstream(OpenChannelsHandler.java:74)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:268)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:255)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:84)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:471)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:332)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:35)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
> 
> > ```
> > at 
> > 
> > ```
> 
> org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
> 
> > ```
> > at 
> > 
> > ```
> 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
> 
> > ```
> > at 
> > 
> > ```
> 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> 
> > |
> > 
> > What is going wrong?
> > 
> > ## Thanks in advance Ulli
> > 
> > You received this message because you are subscribed to the Google  
> > Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send  
> > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [February 19, 2013, 11:22am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-java-api/10795/4 "2013-02-19T11:22:25Z")

</div>

Hey, do you do any large bulk indexing by any chance?

simon

On Tuesday, February 19, 2013 12:16:30 PM UTC+1, Ulli wrote:

> Thanks for your reply. I tried it with 127.0.0.1 and sniff to false but it  
> didn' change anything. InetAddress.getLocalHost() throws an  
> UnknownHostException.  
> But actually I think the exception in the elasticsearch log indicates that  
> at least something is arivung on elasticsearch side. But what does this  
> exception mean?
> 
> Am Dienstag, 19. Februar 2013 10:32:06 UTC+1 schrieb Jörg Prante:
> 
> > You have set sniff to true, that is, your client may be not connecting  
> > to the address you have specified as a transport address ("localhost",  
> > port 9300).
> > 
> > Note, the address the client is connecting to should be the specified  
> > host in the publish\_host setting in each node.
> > 
> > If you want to connect to a multi node cluster, ensure you can reach  
> > every node over the network from your transport client.
> > 
> > In a single node devel setup, you may have not assigned the host name in  
> > /etc/hosts to an IP address. Then you have some options: use 127.0.0.1  
> > instead of "localhost", add the host name to the line where localhost  
> > is declared in /etc/hosts (not recommended for hostname-based network  
> > setups and not always possible), set sniff to false, or write extra code  
> > to find the host name from java and connect to this address instead of  
> > "localhost" - usually something with  
> > InetAddress.getLocalHost().getHostName().
> > 
> > Jörg
> > 
> > Am 19.02.13 10:15, schrieb Ulli:
> > 
> > > Hi,
> > > 
> > > I'm trying to connect to a runnung elasticsearch instance via java api:
> > > 
> > > |  
> > > Settingssettings  
> > > =ImmutableSettings.settingsBuilder().put("cluster.name","elasticsearch").put(
> > 
> > > "client.transport.sniff",true).build();  
> > > this.client
> > 
> > =newTransportClient(settings).addTransportAddress(newInetSocketTransportAddress(
> > 
> > > "localhost",9300));
> > > 
> > > |
> > > 
> > > But the connection failes:
> > > 
> > > |
> > 
> > 2013-02-1910:06:23,983[INFO][elasticsearch[Nova-Prime][generic][T#2]][elasticsearch.client.transport]
> > 
> > > [Nova-Prime] failed to get local cluster state for  
> > > [#transport#-1][inet[localhost/127.0.0.1:9300]], disconnecting...
> > 
> > org.elasticsearch.transport.ReceiveTimeoutTransportException:[inet[localhost/127.0.0.1:9300]][cluster/state]request\_id
> > 
> > > [0]timed outafter [5000ms]  
> > > at
> > 
> > org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:342)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> > 
> > > ```
> > > at java.lang.Thread.run(Thread.java:722) 
> > > 
> > > ```
> > > 
> > > |
> > > 
> > > In the elasticsearch log I see this exception:
> > > 
> > > |  
> > > [10:06:19,023][WARN][transport.netty][master node]exception caught  
> > > on netty layer [[id:0x8920f463,/127.0.0.1:53785 =\> /127.0.0.1:9300]]
> > 
> > org.elasticsearch.common.netty.handler.codec.frame.TooLongFrameException:transport
> > 
> > > content length received [1gb]exceeded [914.1mb]  
> > > at
> > 
> > org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.decode(SizeHeaderFrameDecoder.java:31)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:422)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:793)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.OpenChannelsHandler.handleUpstream(OpenChannelsHandler.java:74)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:268)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:255)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:84)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:471)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:332)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:35)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
> > 
> > > ```
> > > at 
> > > 
> > > ```
> > 
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> > 
> > > |
> > > 
> > > What is going wrong?
> > > 
> > > ## Thanks in advance Ulli
> > > 
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ulli](https://avatars.discourse-cdn.com/v4/letter/u/f04885/32.png) [@Ulli](https://discuss.elastic.co/u/Ulli)\
**Post date:** [February 19, 2013, 11:57am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-java-api/10795/5 "2013-02-19T11:57:18Z")

</div>

I don't do any indexing at all. I have an elasticsearch instance with _one_document in the index and I try to connect to this instance.

Am Dienstag, 19. Februar 2013 12:22:25 UTC+1 schrieb simonw:

> Hey, do you do any large bulk indexing by any chance?
> 
> simon
> 
> On Tuesday, February 19, 2013 12:16:30 PM UTC+1, Ulli wrote:
> 
> > Thanks for your reply. I tried it with 127.0.0.1 and sniff to false but  
> > it didn' change anything. InetAddress.getLocalHost() throws an  
> > UnknownHostException.  
> > But actually I think the exception in the elasticsearch log indicates  
> > that at least something is arivung on elasticsearch side. But what does  
> > this exception mean?
> > 
> > Am Dienstag, 19. Februar 2013 10:32:06 UTC+1 schrieb Jörg Prante:
> > 
> > > You have set sniff to true, that is, your client may be not connecting  
> > > to the address you have specified as a transport address ("localhost",  
> > > port 9300).
> > > 
> > > Note, the address the client is connecting to should be the specified  
> > > host in the publish\_host setting in each node.
> > > 
> > > If you want to connect to a multi node cluster, ensure you can reach  
> > > every node over the network from your transport client.
> > > 
> > > In a single node devel setup, you may have not assigned the host name in  
> > > /etc/hosts to an IP address. Then you have some options: use 127.0.0.1  
> > > instead of "localhost", add the host name to the line where localhost  
> > > is declared in /etc/hosts (not recommended for hostname-based network  
> > > setups and not always possible), set sniff to false, or write extra code  
> > > to find the host name from java and connect to this address instead of  
> > > "localhost" - usually something with  
> > > InetAddress.getLocalHost().getHostName().
> > > 
> > > Jörg
> > > 
> > > Am 19.02.13 10:15, schrieb Ulli:
> > > 
> > > > Hi,
> > > > 
> > > > I'm trying to connect to a runnung elasticsearch instance via java  
> > > > api:
> > > > 
> > > > |  
> > > > Settingssettings  
> > > > =ImmutableSettings.settingsBuilder().put("cluster.name","elasticsearch").put(
> > > 
> > > > "client.transport.sniff",true).build();  
> > > > this.client
> > > 
> > > =newTransportClient(settings).addTransportAddress(newInetSocketTransportAddress(
> > > 
> > > > "localhost",9300));
> > > > 
> > > > |
> > > > 
> > > > But the connection failes:
> > > > 
> > > > |
> > > 
> > > 2013-02-1910:06:23,983[INFO][elasticsearch[Nova-Prime][generic][T#2]][elasticsearch.client.transport]
> > > 
> > > > [Nova-Prime] failed to get local cluster state for  
> > > > [#transport#-1][inet[localhost/127.0.0.1:9300]], disconnecting...
> > > 
> > > org.elasticsearch.transport.ReceiveTimeoutTransportException:[inet[localhost/127.0.0.1:9300]][cluster/state]request\_id
> > > 
> > > > [0]timed outafter [5000ms]  
> > > > at
> > > 
> > > org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:342)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> > > 
> > > > ```
> > > > at java.lang.Thread.run(Thread.java:722) 
> > > > 
> > > > ```
> > > > 
> > > > |
> > > > 
> > > > In the elasticsearch log I see this exception:
> > > > 
> > > > |  
> > > > [10:06:19,023][WARN][transport.netty][master node]exception caught  
> > > > on netty layer [[id:0x8920f463,/127.0.0.1:53785 =\> /127.0.0.1:9300]]
> > > 
> > > org.elasticsearch.common.netty.handler.codec.frame.TooLongFrameException:transport
> > > 
> > > > content length received [1gb]exceeded [914.1mb]  
> > > > at
> > > 
> > > org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.decode(SizeHeaderFrameDecoder.java:31)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:422)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:793)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.OpenChannelsHandler.handleUpstream(OpenChannelsHandler.java:74)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:268)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:255)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:84)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:471)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:332)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:35)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
> > > 
> > > > ```
> > > > at 
> > > > 
> > > > ```
> > > 
> > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> > > 
> > > > |
> > > > 
> > > > What is going wrong?
> > > > 
> > > > ## Thanks in advance Ulli
> > > > 
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [February 19, 2013, 10:35pm UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-java-api/10795/6 "2013-02-19T22:35:23Z")

</div>

The exception means that you should add your host name to /etc/hosts.

Jörg

On Tuesday, February 19, 2013 12:16:30 PM UTC+1, Ulli wrote:

> Thanks for your reply. I tried it with 127.0.0.1 and sniff to false but it  
> didn' change anything. InetAddress.getLocalHost() throws an  
> UnknownHostException.  
> But actually I think the exception in the elasticsearch log indicates that  
> at least something is arivung on elasticsearch side. But what does this  
> exception mean?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ulli](https://avatars.discourse-cdn.com/v4/letter/u/f04885/32.png) [@Ulli](https://discuss.elastic.co/u/Ulli)\
**Post date:** [February 20, 2013, 8:41am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-java-api/10795/7 "2013-02-20T08:41:25Z")

</div>

The host name is in /etc/hosts and I'm not talking about the  
UnknownHostException but the TooLongFrameException mentioned in my original  
posting.

Am Dienstag, 19. Februar 2013 23:35:23 UTC+1 schrieb Jörg Prante:

> The exception means that you should add your host name to /etc/hosts.
> 
> Jörg
> 
> On Tuesday, February 19, 2013 12:16:30 PM UTC+1, Ulli wrote:
> 
> > Thanks for your reply. I tried it with 127.0.0.1 and sniff to false but  
> > it didn' change anything. InetAddress.getLocalHost() throws an  
> > UnknownHostException.  
> > But actually I think the exception in the elasticsearch log indicates  
> > that at least something is arivung on elasticsearch side. But what does  
> > this exception mean?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [February 20, 2013, 2:36pm UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-java-api/10795/8 "2013-02-20T14:36:00Z")

</div>

|TooLongFrameException is thrown if you connect with a client of another  
ES version to an ES cluster (protocol mismatch, in recent ES versions  
this is cleaned up), or you |confused port 9300 with 9200 (so HTTP  
requests are effectivley rejected by the transport protocol layer), or  
you do indeed request to transport too large data chunks via Netty, so  
that ES refuses to accept it (maximum default is 1/4 of the heap size IIRC).

Jörg

Am 20.02.13 09:41, schrieb Ulli:

> The host name is in /etc/hosts and I'm not talking about the  
> UnknownHostException but the |TooLongFrameExceptionmentioned in my  
> original posting.|

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:50am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-java-api/10795/9 "2017-07-06T02:50:32Z")

</div>


