# Java Client and Elasticsearch Transport Proxy

**URL:** <https://discuss.elastic.co/t/java-client-and-elasticsearch-transport-proxy/21183>\
**Category:** Elasticsearch\
**Created:** [December 10, 2014, 10:10am UTC](https://discuss.elastic.co/t/java-client-and-elasticsearch-transport-proxy/21183 "2014-12-10T10:10:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kim\_Baddeley](https://avatars.discourse-cdn.com/v4/letter/k/db5fbb/32.png) [@Kim\_Baddeley](https://discuss.elastic.co/u/Kim_Baddeley)\
**Post date:** [December 10, 2014, 10:10am UTC](https://discuss.elastic.co/t/java-client-and-elasticsearch-transport-proxy/21183/1 "2014-12-10T10:10:53Z")

</div>

Hi,

I have an Elasticsearch cluster running in the cloud and I am trying to  
connect from a java client locally. Due to firewall restrictions I am not  
allowed to connect out on port 9300 from my local client. I have created a  
proxy in the cloud to forward all TCP connections from port 80 to port 9300  
on the cluster master node. My client has the same cluster name as the  
master.

In my Java code I have

Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
"mycluster").build();  
TransportClient client = new TransportClient(settings);  
client.addTransportAddress(new  
InetSocketTransportAddress("{my-proxy-host-ip}", 80));

When trying to access the client I get

[10:00:44] netty - [Hellion] exception caught on transport layer [[id:  
0x2882f1d8, /145.36.217.4:49318 =\> /{my-proxy-host-ip}:80]], closing  
connection  
java.io.StreamCorruptedException: invalid internal transport message format  
at  
org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.decode(SizeHeaderFrameDecoder.java:46)  
at  
org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:425)  
at  
org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)  
at  
org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)  
at  
org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)  
at  
org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)  
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:88)  
at  
org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)  
at  
org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)  
at  
org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)  
at  
org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)  
at  
org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)  
at  
org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:724)

(I have confirmed the route to the master node via the proxy by changing  
the outbound port on the proxy server to 9200 and successfully testing curl  
{my-proxy-host-ip} OK)

I can't see any reason why this shouldn't work so any ideas are welcomed.

Thanks in advance.  
Kim

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [December 10, 2014, 1:46pm UTC](https://discuss.elastic.co/t/java-client-and-elasticsearch-transport-proxy/21183/2 "2014-12-10T13:46:07Z")

</div>

You have configured a HTTP proxy. The transport protocol is binary and not  
HTTP.

What you want is a SOCKS proxy.

Jörg

On Wed, Dec 10, 2014 at 11:10 AM, Kim Baddeley [kim.baddeley@gmail.com](mailto:kim.baddeley@gmail.com)  
wrote:

> Hi,
> 
> I have an Elasticsearch cluster running in the cloud and I am trying to  
> connect from a java client locally. Due to firewall restrictions I am not  
> allowed to connect out on port 9300 from my local client. I have created a  
> proxy in the cloud to forward all TCP connections from port 80 to port 9300  
> on the cluster master node. My client has the same cluster name as the  
> master.
> 
> In my Java code I have
> 
> Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
> "mycluster").build();  
> TransportClient client = new TransportClient(settings);  
> client.addTransportAddress(new  
> InetSocketTransportAddress("{my-proxy-host-ip}", 80));
> 
> When trying to access the client I get
> 
> [10:00:44] netty - [Hellion] exception caught on transport layer [[id:  
> 0x2882f1d8, /145.36.217.4:49318 =\> /{my-proxy-host-ip}:80]], closing  
> connection  
> java.io.StreamCorruptedException: invalid internal transport message format  
> at  
> org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.decode(SizeHeaderFrameDecoder.java:46)  
> at  
> org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:425)  
> at  
> org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)  
> at  
> org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)  
> at  
> org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)  
> at  
> org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)  
> 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:88)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)  
> at  
> org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)  
> at  
> org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)  
> at  
> org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> at java.lang.Thread.run(Thread.java:724)
> 
> (I have confirmed the route to the master node via the proxy by changing  
> the outbound port on the proxy server to 9200 and successfully testing curl  
> {my-proxy-host-ip} OK)
> 
> I can't see any reason why this shouldn't work so any ideas are welcomed.
> 
> Thanks in advance.  
> Kim
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFHxDCqX2m%3DRXwNbLwmOYPobASSZ6iJrfPipnE8VaEz2g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFHxDCqX2m%3DRXwNbLwmOYPobASSZ6iJrfPipnE8VaEz2g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Kim\_Baddeley](https://avatars.discourse-cdn.com/v4/letter/k/db5fbb/32.png) [@Kim\_Baddeley](https://discuss.elastic.co/u/Kim_Baddeley)\
**Post date:** [December 10, 2014, 2:27pm UTC](https://discuss.elastic.co/t/java-client-and-elasticsearch-transport-proxy/21183/3 "2014-12-10T14:27:39Z")

</div>

I have configured a TCP proxy not an HTTP proxy. Have tried this using both  
AWS ELB and EC2 running "socat LISTEN-TCP:80,fork TCP:10.178.241.66:9300"  
with the same result.

Kim

On Wednesday, 10 December 2014 13:46:14 UTC, Jörg Prante wrote:

> You have configured a HTTP proxy. The transport protocol is binary and not  
> HTTP.
> 
> What you want is a SOCKS proxy.
> 
> Jörg
> 
> On Wed, Dec 10, 2014 at 11:10 AM, Kim Baddeley \<[kim.ba...@gmail.com](mailto:kim.ba...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Hi,
> > 
> > I have an Elasticsearch cluster running in the cloud and I am trying to  
> > connect from a java client locally. Due to firewall restrictions I am not  
> > allowed to connect out on port 9300 from my local client. I have created a  
> > proxy in the cloud to forward all TCP connections from port 80 to port 9300  
> > on the cluster master node. My client has the same cluster name as the  
> > master.
> > 
> > In my Java code I have
> > 
> > Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
> > "mycluster").build();  
> > TransportClient client = new TransportClient(settings);  
> > client.addTransportAddress(new  
> > InetSocketTransportAddress("{my-proxy-host-ip}", 80));
> > 
> > When trying to access the client I get
> > 
> > [10:00:44] netty - [Hellion] exception caught on transport layer [[id:  
> > 0x2882f1d8, /145.36.217.4:49318 =\> /{my-proxy-host-ip}:80]], closing  
> > connection  
> > java.io.StreamCorruptedException: invalid internal transport message  
> > format  
> > at  
> > org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.decode(SizeHeaderFrameDecoder.java:46)  
> > at  
> > org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:425)  
> > at  
> > org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)  
> > at  
> > org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)  
> > at  
> > org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)  
> > at  
> > org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)  
> > 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:88)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)  
> > at  
> > org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)  
> > at  
> > org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > at java.lang.Thread.run(Thread.java:724)
> > 
> > (I have confirmed the route to the master node via the proxy by changing  
> > the outbound port on the proxy server to 9200 and successfully testing curl  
> > {my-proxy-host-ip} OK)
> > 
> > I can't see any reason why this shouldn't work so any ideas are welcomed.
> > 
> > Thanks in advance.  
> > Kim
> > 
> > --  
> > 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:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

On Wednesday, 10 December 2014 13:46:14 UTC, Jörg Prante wrote:

> You have configured a HTTP proxy. The transport protocol is binary and not  
> HTTP.
> 
> What you want is a SOCKS proxy.
> 
> Jörg
> 
> On Wed, Dec 10, 2014 at 11:10 AM, Kim Baddeley \<[kim.ba...@gmail.com](mailto:kim.ba...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Hi,
> > 
> > I have an Elasticsearch cluster running in the cloud and I am trying to  
> > connect from a java client locally. Due to firewall restrictions I am not  
> > allowed to connect out on port 9300 from my local client. I have created a  
> > proxy in the cloud to forward all TCP connections from port 80 to port 9300  
> > on the cluster master node. My client has the same cluster name as the  
> > master.
> > 
> > In my Java code I have
> > 
> > Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
> > "mycluster").build();  
> > TransportClient client = new TransportClient(settings);  
> > client.addTransportAddress(new  
> > InetSocketTransportAddress("{my-proxy-host-ip}", 80));
> > 
> > When trying to access the client I get
> > 
> > [10:00:44] netty - [Hellion] exception caught on transport layer [[id:  
> > 0x2882f1d8, /145.36.217.4:49318 =\> /{my-proxy-host-ip}:80]], closing  
> > connection  
> > java.io.StreamCorruptedException: invalid internal transport message  
> > format  
> > at  
> > org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.decode(SizeHeaderFrameDecoder.java:46)  
> > at  
> > org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:425)  
> > at  
> > org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)  
> > at  
> > org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)  
> > at  
> > org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)  
> > at  
> > org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)  
> > 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:88)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)  
> > at  
> > org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)  
> > at  
> > org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)  
> > at  
> > org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > at java.lang.Thread.run(Thread.java:724)
> > 
> > (I have confirmed the route to the master node via the proxy by changing  
> > the outbound port on the proxy server to 9200 and successfully testing curl  
> > {my-proxy-host-ip} OK)
> > 
> > I can't see any reason why this shouldn't work so any ideas are welcomed.
> > 
> > Thanks in advance.  
> > Kim
> > 
> > --  
> > 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:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c356c021-9d01-4ed4-926e-85ebaa7bc7a5%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/053a48bc-49d2-4cf2-b261-ad399bf8de64%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/053a48bc-49d2-4cf2-b261-ad399bf8de64%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:44am UTC](https://discuss.elastic.co/t/java-client-and-elasticsearch-transport-proxy/21183/4 "2017-07-06T00:44:26Z")

</div>


