Hi
I create new topic because I did not find a solution to my pb in the other threads.
My pb is that I face the following error when I try to perform a search query on elasticsearch thanks a java client:
InetSocketAddress: NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{mqrDOkH-Sbu4haRYxMekXg}{xxx.xxx.xxx.xxx}{xxx.xxx.xxx.xxx:9300}]]
Here is a curl where I can see my cluster informations:
curl -XGET 'xxx.xxx.xxx.xxx/'
{
"name" : "my-node-name-1",
"cluster_name" : "my-cluster-name",
"cluster_uuid" : "lmhoyPBWQTu2SSt-3BabRg",
"version" : {
"number" : "5.4.0",
"build_hash" : "780f8c4",
"build_date" : "2017-04-28T17:43:27.229Z",
"build_snapshot" : false,
"lucene_version" : "6.5.0"
},
"tagline" : "You Know, for Search"
}
I think I have the right versions for the librairies I use to connect, here is my pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test.elasticsearch</groupId>
<artifactId>TestElasticSearch</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>transaction-generator</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And I'm using this class I found on this forum:
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.NoNodeAvailableException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
public class TrivialClient {
public static void main(String[] args) throws UnknownHostException {
String host = "xxx.xxx.xxx.xxx";
InetSocketTransportAddress transportAddress = new InetSocketTransportAddress(
InetAddress.getByName(host), 9300);
createClientPrintResponse("getByName("xxx.xxx.xxx.xxx)", transportAddress);
transportAddress =
new InetSocketTransportAddress(new InetSocketAddress(host, 9300));
createClientPrintResponse("InetSocketAddress", transportAddress);
}
private static void createClientPrintResponse(String description,
InetSocketTransportAddress transportAddress) {
System.out.println("begining : " + description + "... ");
Settings settings = Settings.builder()
.put("cluster.name", "my-cluster-name").build();
Client client;
client = new PreBuiltTransportClient(settings).
addTransportAddress(transportAddress);
try {
GetResponse response = client.prepareGet("comicbook", "superhero", "1").get();
System.out.println(description + ": " + response);
} catch (NoNodeAvailableException e) {
System.out.println(description + ": " + e);
//e.printStackTrace();
}
}
}
Does somebody now what I'm doing wrong? Or what I miss?