Java API connect the ES


(levi) #1

Dear team,
recently, I using the java API connect the ES 2.3.3 client which has installed the shield. the error as flows:

     Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available:

BTW, I cannot found the user and password setting in elasticsearch.yml. here was my java code:

public static Client getEsConnection()
{
String clusterName = "elasticsearch";

    Settings settings = Settings.settingsBuilder()
            .put("cluster.name", clusterName)
            .build();
    Client client = null;
    try {
        client = TransportClient.builder().settings(settings).build()
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("10.xx.xx.xx"), 9300))
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("10.xx.xx.xx"), 9300))
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("10.xx.xx.xx"), 9300));

    } catch (UnknownHostException e) {
        e.printStackTrace();
    }

    return client;

}

Levi,
thanks


(David Pilato) #2

Here we go: https://www.elastic.co/guide/en/shield/current/_using_elasticsearch_java_clients_with_shield.html


(levi) #3

Thanks for quick response!


(levi) #4

Thanks for dadoonet , I resolve it fallowing the url!


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.