Problem with Transport client and elasticsearch cluster behind load balancer

Hallo,

I try to use elasticsearch for "search suggestion" in a java-webapplication.
There are 2 nodes in the cluster behind a load balancer.
I use elasticsearch 1.5

My problem is, if I use Transport Client with node host addresses there is no problem.

Client transportClient = new TransportClient(settings())
.addTransportAddress(new InetSocketTransportAddress("elastic-suggest1.de", 9300))
.addTransportAddress(new InetSocketTransportAddress("elastic-suggest2.de", 9300));

but if I try to use the load balancer with load balancer host address

Client client = new TransportClient(settings())
.addTransportAddress(new InetSocketTransportAddress("load_balancer_host.de", 80));

I get an error
elasticsearch[Blue Diamond][transport_client_worker][T#20]{New I/O worker #20} deploymentPhase
WARN org.elasticsearch.transport.netty - [Blue Diamond] exception caught on transport layer [[id: 0x6f6cd7f0, /xx.xxx.xxx.xxx:41411 => load_balancer_host.de/xx.xxx.xxx.xxx:80]], closing connection
java.io.IOException: Die Wartezeit fuer die Verbindung ist abgelaufen // =time out
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:384)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:64)
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:337)
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:745)

and the second error:
None of the configured nodes were available: [[suggest1][l6ReVYRRSeqz8CT9aSHnEA][elastic-suggest1.de][inet[load_balancer_host.de/xx.xxx.xxx.xxx:80]]]

Can somebody help me to find a solution for this problem?

best regards,
Tanja

Transport client establishes and maintains connections with other nodes and performs load balancing and fault detection between these connection. An external load balancing is hindering with this process in two ways - first of all it breaks idle connections (I think this is main cause for the error that you are seeing) and second since the transport client establishes the connection only ones, the load balancer basically limits the communication from the transport client to a single node that it connected to. In other words using load balancer on the transport protocol is a bad idea. You should ether remove the load balancer, or switch to REST client if having load balancer between the client and elasticsearch is a requirement.

1 Like

Great help, thx