I get the following error when trying to connect to Elasticsearch 2 using the Java API for ES 2. This is the code:
Settings settings = Settings.settingsBuild
The problem might be in the settings that you are using.
Instead of creating the Client in these three steps:
TransportClient transportClient = TransportClient.builder().settings(settings).build();
Client c = null;
try {
c = transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(Receptor.es_ip), 9300));
} catch (UnknownHostException e) {
System.err.println(Util.getTimestampStr() + "UnknownHostException error.");
e.printStackTrace();
}
Try creating it like this:
Client client = new TransportClient()
.addTransportAddress(new InetSocketTransportAddress(
InetAddress.getByName(Receptor.es_ip),
9300));
If you want more data check this old answer to a similar question: Elastic search problems