简体   繁体   中英

Java Transport Client for Elasticsearch throws NoNodeAvailableException

I am new to elasticsearch and trying to connect to a remote cluster running version 1.5.2. I have added the same version Maven dependency to my project. I am initializing the Transport client using the following Scala code:

val settings: Settings = ImmutableSettings.settingsBuilder().put("cluster.name", "clusterName").put("client.transport.sniff", true).build()
val client: Client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("XX.X.X.XX", 9300))

It then fails when i try to check if an index exists:

val exists = client.admin().indices().prepareExists("index").execute().actionGet().isExists()

"clusterName" matches the property 'cluster.name' in the elasticsearch.yml on the cluster. I have also tried upping the client.transport.ping_timeout and client.transport.nodes_sampler_interval to 30s to no avail and tried both with and without sniffing.

I have used curl on port 9200 to verify that i can index and search on my elasticsearch instance.

Relevant Stack trace:

org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []
    at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:305)
    at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:200)
    at org.elasticsearch.client.transport.support.InternalTransportIndicesAdminClient.execute(InternalTransportIndicesAdminClient.java:86)
    at org.elasticsearch.client.support.AbstractIndicesAdminClient.exists(AbstractIndicesAdminClient.java:170)
    at org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder.doExecute(IndicesExistsRequestBuilder.java:53)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)

Thanks in advance for any assistance.

我知道这是一个非常古老的问题,但我知道针对这种情况的一种解决方法是在您的设置中将嗅探添加到 false

put("client.transport.sniff", false)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM