" NoNodeAvailableExceptionException"由TransportClient类抛出

时间:2016-04-25 11:42:20

标签: java networking elasticsearch

我是ElasticSearch v2.3.1的新用户并尝试使用elasticsearch

连接到TransportClient群集

我的代码就像:

Settings settings = Settings.settingsBuilder().put("cluster.name", "my-cluster").put("client.transport.sniff", true)..put("shield.user", "transport_client_user:user")build();
Client client = TransportClient.builder().addPlugin(ShieldPlugin.class).settings(settings).build().addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("localhost", 9200)));
GetResponse getResponse = client.prepareGet("megacorp", "employee", "1").get();

我已经验证了服务器,并且它在上述端口(9200)上正常运行。 索引也就位,并通过Sense

直接查询elasticsearch服务器进行检查

上面的代码在Java End上抛出以下异常:

Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{127.0.0.1}{localhost/127.0.0.1:9200}]]
    at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:290)
    at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:207)
    at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
    at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:288)
    at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56)
    at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:64)
    at com.elastic.GET.callMe(GET.java:50)
    at com.elastic.GET.main(GET.java:33)

在Elasticsearch服务器控制台上,例外是:

[2016-04-25 16:16:13,488][WARN ][shield.transport.netty   ] [Pete Wisdom] Caught exception while handling client http traffic, closing connection [0x79694953, /127.0.0.1:56521 => /127.0.0.1:9200]
java.lang.IllegalArgumentException: empty text
        at org.jboss.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:89)
        at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62)
        at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75)
        at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:191)
        at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:102)
        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500)

我已尝试按照某些帖子的建议将端口更改为9300,但无济于事。

当我尝试点击时,我在elasticsearch服务器控制台上也看到了同样的异常 https://localhost:9200 来自浏览器。

因此,传输客户端可能正在尝试连接到https://localhost:9200 - 这是可能的。 如果是,请如何从新http://localhost

获取InetSocketAddress()

感谢您的帮助。

0 个答案:

没有答案