Elastic Search 5 on Microsoft Azure Connection Failure

I am new to elastic search and I have created a 3 node elastic search cluster in Microsoft Azure using the "Elastic Stack" template. But I am not able to connect to the cluster using connection pool or using a single node connection.

Here's my code:
var uris = new[]
{
new Uri("http://<>:9200")
};

            var connectionPool = new SniffingConnectionPool(uris);

            var settings = new ConnectionSettings(connectionPool)
                .SniffOnConnectionFault(false)
                .SniffOnStartup(false)
                .RequestTimeout(TimeSpan.FromSeconds(500))
                .PingTimeout(TimeSpan.FromSeconds(500))
                .MaximumRetries(5)
                .DefaultIndex("people");

            var client = new ElasticClient(settings);

It gives me the error:
FailureReason: PingFailure while attempting PUT on http://<>:9200/people/person/1

Audit trail of this API call:

OriginalException: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.0.2.4:9200

at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at Elasticsearch.Net.HttpConnection.Request[TReturn](RequestData requestData)

Request:

<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>

Response:

<Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>

Inner Exception: One or more errors occurred.

System.AggregateException: One or more errors occurred. ---> Elasticsearch.Net.PipelineException: Failed to ping the specified node. ---> Elasticsearch.Net.PipelineException: An error occurred trying to read the response from the specified node.
at Elasticsearch.Net.RequestPipeline.Ping(Node node)
--- End of inner exception stack trace ---
at Elasticsearch.Net.RequestPipeline.Ping(Node node)
at Elasticsearch.Net.Transport1.Ping(IRequestPipeline pipeline, Node node) at Elasticsearch.Net.Transport1.Request[TReturn](HttpMethod method, String path, PostData1 data, IRequestParameters requestParameters) --- End of inner exception stack trace --- ---> (Inner Exception #0) Elasticsearch.Net.PipelineException: Failed to ping the specified node. ---> Elasticsearch.Net.PipelineException: An error occurred trying to read the response from the specified node. at Elasticsearch.Net.RequestPipeline.Ping(Node node) --- End of inner exception stack trace --- at Elasticsearch.Net.RequestPipeline.Ping(Node node) at Elasticsearch.Net.Transport1.Ping(IRequestPipeline pipeline, Node node)
at Elasticsearch.Net.Transport1.Request[TReturn](HttpMethod method, String path, PostData1 data, IRequestParameters requestParameters)<---

Exception:

Elasticsearch.Net.ElasticsearchClientException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> Elasticsearch.Net.PipelineException: Failed to ping the specified node. ---> Elasticsearch.Net.PipelineException: An error occurred trying to read the response from the specified node.
at Elasticsearch.Net.RequestPipeline.Ping(Node node)
--- End of inner exception stack trace ---
at Elasticsearch.Net.RequestPipeline.Ping(Node node)
at Elasticsearch.Net.Transport1.Ping(IRequestPipeline pipeline, Node node) at Elasticsearch.Net.Transport1.Request[TReturn](HttpMethod method, String path, PostData`1 data, IRequestParameters requestParameters)
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---

Any suggestions , what I could be missing?

OriginalException: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.0.2.4:9200

It looks like your trying to connect to the node through its local IP address rather than through a public IP address.

If you're using Elastic's Azure ARM template to deploy a cluster, you'll need to deploy either an external load balancer or Application Gateway in order to connect to the cluster from outside of the virtual network;

If you're deploying through the Azure Marketplace portal:

if you're deploying through Azure CLI or PowerShell:

You can specify the loadBalancerType as either external for external load balancer or gateway for Application Gateway.

You may also find the blog post on deploying Elasticsearch and Kibana to Azure useful.

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