Getting ElasticsearchSecurityException while working with ES 5.4.0

I am trying to use ElasticSearch 5.4.0 to create a TransportClient and utilize it for indexing records in my local ES cluster. The client, I have created, is as follows:

@SuppressWarnings({ "resource", "unchecked" })
protected static Client getTransportClient() {
    try {
        Settings settings = Settings.builder()
                .put("", "username:password")
                //.put("", false)
        InetSocketTransportAddress inetAddress = new InetSocketTransportAddress(InetAddress.getByName(""), 9300);
        client = new PreBuiltXPackTransportClient(settings).addTransportAddress(inetAddress);
    } catch (UnknownHostException e) {
        LOGGER.log(Level.WARNING, e.getMessage());
    return client;

But, when I try to use the client to prepare an index as follows:

IndexResponse response = client.prepareIndex(INDEX, TYPE)

i got the following error:

Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{Vydx3TkcTReJh71fcCjqQg}{}{}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(
at org.elasticsearch.client.transport.TransportClientNodesService.execute(
at org.elasticsearch.client.transport.TransportProxyClient.execute(
at org.elasticsearch.client.transport.TransportClient.doExecute(
at org.elasticsearch.action.ActionRequestBuilder.execute(
at org.elasticsearch.action.ActionRequestBuilder.execute(
at org.personal.elastic.twitter.ElasticUtil.indexTweet(
at org.personal.elastic.twitter.TweetHunter.main(

The error log itself didn't help much, so I looked up further. I found out that my ES node was, in fact, found out but was dropped during network handshake. The internal error log (which didn't show up in the previous stack trace) can be found here:

Could someone help me resolving this issue, which looks like related to ES x-pack authentication. Please let me know, if any further information is required.

I'm getting the same error with 5.4.0 and 5.4.1.

Much sadness.

The most likely cause of this error is that you are connecting to the server without configuring SSL (TLS) correctly for that cluster.

Generally speaking, the transport client needs to have all the same SSL settings as the server.
For example, something like:

        .put("", user + ":" + password)
        .put("", true)
        .put("", "true")
        .putArray("xpack.ssl.certificate_authorities", conf + "/tls/ca/ca.crt")
        .put("xpack.ssl.certificate", conf + "/tls/client-node/client-node.crt")
        .put("xpack.ssl.key", conf + "/tls/client-node/client-node.key")

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