TransportClient hangs when connecting to cluster

Hello. I try to use TransportClient like this:

new
TransportClient(ImmutableSettings.settingsBuilder().put("client.transport.sniff",
false)).addTransportAddress(new InetSocketTransportAddress("127.0.0.1",
9200))

It hangs on:
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)

  • parking to wait for <0x00007fa82be40710> (a
    org.elasticsearch.common.util.concurrent.AbstractFuture$Sync)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
    at
    org.elasticsearch.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:249)
    at
    org.elasticsearch.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:78)
    at
    org.elasticsearch.transport.PlainTransportFuture.txGet(PlainTransportFuture.java:45)
    at
    org.elasticsearch.transport.PlainTransportFuture.txGet(PlainTransportFuture.java:35)
    at
    org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler.sample(TransportClientNodesService.java:199)
  • locked <0x00007fa82b7007e8> (a
    org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler)
    at
    org.elasticsearch.client.transport.TransportClientNodesService.addTransportAddress(TransportClientNodesService.java:122)
    at
    org.elasticsearch.client.transport.TransportClient.addTransportAddress(TransportClient.java:200)

The same behaviour when client.transport.sniff is set to true, but then it
hangs on:
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)

  • parking to wait for <0x00007f35a0967fa0> (a
    java.util.concurrent.CountDownLatch$Sync)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
    at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:207)
    at
    org.elasticsearch.client.transport.TransportClientNodesService$SniffNodesSampler.sample(TransportClientNodesService.java:260)
  • locked <0x00007f35a03d7298> (a
    org.elasticsearch.client.transport.TransportClientNodesService$SniffNodesSampler)
    at
    org.elasticsearch.client.transport.TransportClientNodesService.addTransportAddress(TransportClientNodesService.java:122)
    at
    org.elasticsearch.client.transport.TransportClient.addTransportAddress(TransportClient.java:200)

In my logs I have:
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool [cached],
type [cached], keep_alive [30s]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool [index],
type [cached], keep_alive [5m]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool [search],
type [cached], keep_alive [5m]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool [percolate],
type [cached], keep_alive [5m]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool
[management], type [scaling], min [1], size [20], keep_alive [5m]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool [merge],
type [scaling], min [1], size [20], keep_alive [5m]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool [snapshot],
type [scaling], min [1], size [10], keep_alive [5m]
[org.elasticsearch.transport.netty] : [La Nuit] using worker_count[4],
port[9300-9400], bind_host[null], publish_host[null], compress[false],
connect_timeout[30s], connections_per_node[2/4/1]
[org.elasticsearch.client.transport] : [La Nuit] node_sampler_interval[5s]
[netty.channel.socket.nio.NioProviderMetadata] : Using the autodetected NIO
constraint level: 0
[org.elasticsearch.transport.netty] : [La Nuit] Connected to node
[[#transport#-1][inet[/127.0.0.1:9200]]]

You are connecting to the HTTP port in this case, you need to connect to the
transport port (9300). I tried chasing down why it hangs a few days ago and
does not fail, need to delve down into the netty http parsing code.

2011/8/10 Wojciech Durczyński wojciech.durczynski@comarch.com

Hello. I try to use TransportClient like this:

new
TransportClient(ImmutableSettings.settingsBuilder().put("client.transport.sniff",
false)).addTransportAddress(new InetSocketTransportAddress("127.0.0.1",
9200))

It hangs on:
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)

  • parking to wait for <0x00007fa82be40710> (a
    org.elasticsearch.common.util.concurrent.AbstractFuture$Sync)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
    at
    org.elasticsearch.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:249)
    at
    org.elasticsearch.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:78)
    at
    org.elasticsearch.transport.PlainTransportFuture.txGet(PlainTransportFuture.java:45)
    at
    org.elasticsearch.transport.PlainTransportFuture.txGet(PlainTransportFuture.java:35)
    at
    org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler.sample(TransportClientNodesService.java:199)
  • locked <0x00007fa82b7007e8> (a
    org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler)
    at
    org.elasticsearch.client.transport.TransportClientNodesService.addTransportAddress(TransportClientNodesService.java:122)
    at
    org.elasticsearch.client.transport.TransportClient.addTransportAddress(TransportClient.java:200)

The same behaviour when client.transport.sniff is set to true, but then it
hangs on:
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)

  • parking to wait for <0x00007f35a0967fa0> (a
    java.util.concurrent.CountDownLatch$Sync)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
    at
    java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
    at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:207)
    at
    org.elasticsearch.client.transport.TransportClientNodesService$SniffNodesSampler.sample(TransportClientNodesService.java:260)
  • locked <0x00007f35a03d7298> (a
    org.elasticsearch.client.transport.TransportClientNodesService$SniffNodesSampler)
    at
    org.elasticsearch.client.transport.TransportClientNodesService.addTransportAddress(TransportClientNodesService.java:122)
    at
    org.elasticsearch.client.transport.TransportClient.addTransportAddress(TransportClient.java:200)

In my logs I have:
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool [cached],
type [cached], keep_alive [30s]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool [index],
type [cached], keep_alive [5m]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool [search],
type [cached], keep_alive [5m]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool
[percolate], type [cached], keep_alive [5m]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool
[management], type [scaling], min [1], size [20], keep_alive [5m]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool [merge],
type [scaling], min [1], size [20], keep_alive [5m]
[org.elasticsearch.threadpool] : [La Nuit] creating thread_pool [snapshot],
type [scaling], min [1], size [10], keep_alive [5m]
[org.elasticsearch.transport.netty] : [La Nuit] using worker_count[4],
port[9300-9400], bind_host[null], publish_host[null], compress[false],
connect_timeout[30s], connections_per_node[2/4/1]
[org.elasticsearch.client.transport] : [La Nuit] node_sampler_interval[5s]
[netty.channel.socket.nio.NioProviderMetadata] : Using the autodetected NIO
constraint level: 0
[org.elasticsearch.transport.netty] : [La Nuit] Connected to node
[[#transport#-1][inet[/127.0.0.1:9200]]]

Thank you Shay. It worked :slight_smile:
Also I noticed that settings for TransportClient should contain
"cluster.name". Without it TransportClient doesn't connect to cluster nodes
with different cluster name than "elasticsearch".

Yes, if you use a different cluster name, then it needs to be configured in
the transport client.

2011/8/10 Wojciech Durczyński wojciech.durczynski@comarch.com

Thank you Shay. It worked :slight_smile:
Also I noticed that settings for TransportClient should contain "
cluster.name". Without it TransportClient doesn't connect to cluster nodes
with different cluster name than "elasticsearch".