Getting " failed to connect to node [{#transport#-1}{nE-IOaK-SLWdBf7f80Yo2g}{localhost}{127.0.0.1:9300}], ignoring..."

I get this error when I try to connect to the ElasticSearch v7.2. Here is my setting in elastic.yml file

cluster.name: eml
node.name: eml
path.logs: d:/temp/logs/elastic
http.port: 9200

Here is my application.properties settings:

spring.data.elasticsearch.cluster-name = eml
spring.data.elasticsearch.cluster-nodes=localhost:9300
elasticsearch.host = localhost
elasticsearch.port = 9200
elasticsearch.username=
elasticsearch.password=
elasticsearch.clustername = eml

I use Spring Boot to connect. but also use HighLevelClient API

Here is my code to configure HighLevel Client.

@Configuration
@Slf4j
public class ElasticHighLevelClientConfig {

@Value("${elasticsearch.host}")
private String host;

@Value("${elasticsearch.port}")
private int port;

@Value("${elasticsearch.username}")
private String userName;

@Value("${elasticsearch.password}")
private String password;

@Bean(name = "myEsClient", destroyMethod = "close")
public RestHighLevelClient myRestClient() {
	final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
	credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password));
	RestClientBuilder builder = RestClient.builder(new HttpHost(host, port)).setHttpClientConfigCallback(
			httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
	RestHighLevelClient client = new RestHighLevelClient(builder);
	return client;

}

}

Can you please post here the full error message with complete stacktrace?

Thanks Thiago for taking a look at my issue. Interestingly, I was able to resolve the issue by downgrading ES from 7.2 to 6.8. It seems the current Spring ElasticSearch with Spring Boot 2.1 does not support ES 7.2.

I will be interested to find out if anybody runs ES 7.2 with Spring Boot 2.1.

When using springboot with
elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...

Basically you can put this in your pom.xml:

<properties>
  <elasticsearch.version>7.2.0<elasticsearch.version>
</properties>

See documentation here: “How-to” Guides

I will be interested to find out if anybody runs ES 7.2 with Spring Boot 2.1.

I do. Here: GitHub - dadoonet/legacy-search at 06-fuzziness

Thank you David. I will make the change as you suggested and let you know the outcome. Once again I appreciate your response.

I updated my pom.xml by adding:
<elasticsearch.version>7.2.0</elasticsearch.version>
<beyonder.version>7.0</beyonder.version>

I updated my pom.xml by adding the following properties:
<elasticsearch.version>7.2.0</elasticsearch.version>
<beyonder.version>7.0</beyonder.version>

and the following dependencies:

	 <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>${elasticsearch.version}</version>
    </dependency>
    <!-- this is now needed because of spring parent which forces a 6.4 version -->
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-client</artifactId>
        <version>${elasticsearch.version}</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>${elasticsearch.version}</version>
    </dependency>
    <dependency>
        <groupId>fr.pilato.elasticsearch</groupId>
        <artifactId>elasticsearch-beyonder</artifactId>
        <version>${beyonder.version}</version>
    </dependency>

Now, I get this error
Archive for required library: 'D:/Users/vpatel/.m2/repository/org/elasticsearch/client/transport/7.2.0/transport-7.2.0.jar' in project 'EmployerWebService' cannot be read or is not a valid ZIP file"

I also deleted all files/folder under "D:/Users/vpatel/.m2/repository/org/elasticsearch/client/transport/". But I still get this error.

how about synchronized the maven?

Yes. I did "Update Project" after making the change in the POM.

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