Test Elastic Search Node - CSharp System.Net

CSharp examples for System.Net:HttpWebRequest

Description

Test Elastic Search Node

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Net;
using System.Linq;
using System.Configuration;
using System.Collections.Generic;
using System;/*from   w  w  w.ja  v  a  2s . c  om*/
using Nest;

public class Main{
        private static Boolean TestElasticSearchNode(String uri)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Console.WriteLine("Verified connection to elasticSearch node");
                    return true;
                }

                return false;
            }
            catch
            {
                return false;
            }

        }
}

Related Tutorials