Not able to create the TransportClient of the PreBuiltXPackTransportClient

I am trying to create the Transport client of the PreBuiltXPackTransportClient but getting the below exception:

[err] NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{C5U0OGnqQ0uL4m-_haFBNg}{}{}]]

Below is my configuration:

TransportClient client = new PreBuiltXPackTransportClient(Settings.builder()
.put("", "elasticsearch")
.put("", "transport_client_user:changeme")
.build()).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(""), port));

I have installed the x-pack security feature and its working fine through the rest call but I am facing issue to create the client in java code.

Please help me to resolve the issue.

Thanks in advance.

It should work well like this I think.

May be share elasticsearch logs, formatted please with </> icon.

Also format your code the same way please.

BTW Transport Client will be deprecated in the future. May be better to switch now to the Rest Client instead?

Hi David,

Thanks for reply.

Please find below the elasticsearch logs:

[2017-11-07T05:12:58,149][ERROR][o.e.x.s.a.e.NativeUsersStore] [b3l2K7J] failed to retrieve user [transport_client_user]
org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [SERVICE_UNAVAILABLE/1/state not recovered / initialized];
	at org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedException( ~[elasticsearch-5.6.3.jar:5.6.3]
	at ~[elasticsearch-5.6.3.jar:5.6.3]
	at$AsyncSingleAction.<init>( ~[elasticsearch-5.6.3.jar:5.6.3]/>

So transport_client_user has not been created.

May be you did not read that?

BTW I moved your question to #x-pack

Thanks Devid

Where I need to create the transport_client_user as I have put this in my

        .put("", "transport_client_user:changeme")

I am able to hit the elastic search with http://elastic:changeme@localhost:9200 this means the x-pack configuration is working fine with the elastic/changeme username/password.

I believe you can do it in Kibana -> Management -> Users
Otherwise using the API:

Hi David,

Thanks you.

Still I am getting the below exception:

[err] NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{YLKYvxd5QguJeo1j4kYiMw}{}{}]]

I have created the user:

POST /_xpack/security/user/jacknich
      "password" : "password", 
      "roles" : [ "admin", "superuser" ], 
      "full_name" : "Jack Nicholson", 
      "email" : "", 
      "metadata" : { 
        "intelligence" : 7
      "enabled": true 

After that I have changed the configuration :

    		        .put("", "elasticsearch")
    		        .put("", "transport_client_user:jacknich")

The username and password is same jacknich/jacknich.

The issue has been resolved by changing below

            		        .put("", "elasticsearch")
            		        .put("", "jacknich:jacknich")

There was an issue with the transport_client_user attribute we need to pass the created username here
David Thanks a lot for your help :slight_smile:

1 Like

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