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}{127.0.0.1}{127.0.0.1:9300}]]

Below is my configuration:

TransportClient client = new PreBuiltXPackTransportClient(Settings.builder()
.put("cluster.name", "elasticsearch")
.put("xpack.security.user", "transport_client_user:changeme")
.build()).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 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(ClusterBlocks.java:165) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.action.support.single.shard.TransportSingleShardAction.checkGlobalBlock(TransportSingleShardAction.java:105) ~[elasticsearch-5.6.3.jar:5.6.3]
	at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.<init>(TransportSingleShardAction.java:139) ~[elasticsearch-5.6.3.jar:5.6.3]/>

So transport_client_user has not been created.

May be you did not read that? https://www.elastic.co/guide/en/x-pack/current/java-clients.html

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 configuration.java

        Settings.builder()
        .put("xpack.security.user", "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: https://www.elastic.co/guide/en/x-pack/current/native-realm.html#native-add

Hi David,

Thanks you.

Still I am getting the below exception:

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

I have created the user:

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

After that I have changed the configuration :

    Settings.builder()
    		        .put("cluster.name", "elasticsearch")
    		        .put("xpack.security.user", "transport_client_user:jacknich")

The username and password is same jacknich/jacknich.

The issue has been resolved by changing below

        Settings.builder()
            		        .put("cluster.name", "elasticsearch")
            		        .put("xpack.security.user", "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.