Elasticsearch basic client connection

怎甘沉沦 提交于 2019-12-12 03:35:42

问题


I have setup a SSH tunnel on port 9300 to my remote elasticsearch server.

When running this basic example to get the example data from the elasticsearch instance I get a "org.elasticsearch.client.transport.NoNodeAvailableException: No node available"

Settings settings = ImmutableSettings.settingsBuilder()
            .build();

    Client client = new TransportClient(settings).addTransportAddress(
            new InetSocketTransportAddress(InetAddress.getLocalHost().getHostName(), 9300));


    GetResponse getResponse = client.prepareGet("bank", "account", "25").execute().actionGet();

回答1:


my setup is that i connect from my localhost to a remote machine where elasticsearch is running in a docker-container and i got the same problem on port 9300 using transportclient with netty4. connecting to the tunneled port 9200 was no problem

transport.publish_host: localhost

has fixed it

so my es.yml has now:

http.host: 0.0.0.0
transport.host: 172.18.0.33
transport.publish_host: localhost

and i do the tunnel via:

ssh -N -L 9300:172.18.0.33:9300 user@server.com


来源:https://stackoverflow.com/questions/38433615/elasticsearch-basic-client-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!