Pierre Jones
Pierre Jones

Reputation: 662

Elasticsearch 7.10.2 doesn't bind application.properties variables on Mac M1

I'm facing a weird issue. I have 2 laptops, one running under Windows where everything works fine and on the other side, a Mac Mini M1.

Assuming, I'm developing a basic Spring Boot application with Elasticsearch as Repository. In the application.yml, as usual I have the following properties :

spring:
  elasticsearch:
    rest:
      uris: https://dummy-cloud-provider.cloud.com:12833
      username: myusername
      password: mypassword

But everytime I want to start the application on my Mac, I have the following error :

2021-06-23 15:55:51.972 ERROR [reactor-http-nio-3] r.c.p.Operators - Operator called default onErrorDropped
reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.data.elasticsearch.client.NoReachableHostException: Host 'localhost:9200' not reachable. Cluster state is offline.
Caused by: org.springframework.data.elasticsearch.client.NoReachableHostException: Host 'localhost:9200' not reachable. Cluster state is offline.
    at org.springframework.data.elasticsearch.client.reactive.SingleNodeHostProvider.lambda$lookupActiveHost$3(SingleNodeHostProvider.java:101)
    at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:102)
    at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:220)
    at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
    at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2397)
    ...

I don't understand why it always skip my application.yml variables and try to reach localhost:9200.

I hope someone can help me :)

Best regards

Upvotes: 0

Views: 303

Answers (2)

Isuru
Isuru

Reputation: 722

For anyone looking for Spring Data Elasticsearch config application.yml for Elastic Search version 8.x

spring:
  elasticsearch:
    username: elastic
    password: changeme
    uris: http://localhost:9200

Upvotes: 0

Abacus
Abacus

Reputation: 19471

This is not a Spring Data Elasticsearch problem, but a Spring Boot problem. Spring Data Elasticsearch does not use application properties to set anything up.

Looking at the configuration it seems that you want to set up a imperative (non-reactive) client connection to Elasticsearch?

The stacktrace shows that the failing call is done by the reactive client.

I suspect that you have the reactive Spring libraries (webflux) in the classpath and Spring boot actuator. And Spring Boot then configures a reactive client for the actuator using the default of localhost:9200.

I can't tell for sure without seeing your maven/gradle setup, but this for me is most possible explanation for this error.

Upvotes: 1

Related Questions