Could not create connect to elastic server

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Could not create connect to elastic server

This post has NOT been accepted by the mailing list yet.
This post was updated on .
Dear Mr/Mrs!

I want to use elastic search in my webapp, so this is my problem.
I create new client as below:
public static Client createClient() {
                try {
                        // Node node =
                        // nodeBuilder().clusterName(IConstants.CONFIG.CLUSTER_NAME).node();
                        // client = node.client();
                        Settings settings = ImmutableSettings.settingsBuilder()
                                        .put("client.transport.sniff", true)
                                        .put("", IConstants.CONFIG.CLUSTER_NAME)

                        TransportClient transportClient = new TransportClient(settings);
                                        new InetSocketTransportAddress(IConstants.CONFIG.NODE1,
                                        new InetSocketTransportAddress(IConstants.CONFIG.NODE2,

                        if (transportClient.connectedNodes().size() == 0) {
                                                .println("There are no active nodes available for the transport, it will be automatically added once nodes are live!");

                        client = transportClient;
                } catch (Exception e) {
                        throw e;
                return client;

My problem is if i deploy web on server, then TransportClient transportClient = new TransportClient(settings); breaked without exception, so client = null;

But if i use some code to test it in local, it works.

Please, help me!
Thank you.