1
votes

I am using elasticsearch7.5. I have turned on the following properties

xpack.security.enabled: true
xpack.security.authc.api_key.enabled: true

I have generated API keys to connect our springboot to elasticsearch.I am using

spring-boot-starter-data-elasticsearch

All my requests are from "RestHighClient" and able to trigger the requests.Only problem is during server startup, they are some errors where it is not able to connect to Elasticsearch.

org.elasticsearch.transport.RemoteTransportException: [ADMIN-PC][127.0.0.1:9300][cluster:monitor/nodes/liveness]
Caused by: org.elasticsearch.ElasticsearchSecurityException: missing authentication credentials for action [cluster:monitor/nodes/liveness]

In pom.xml

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>transport</artifactId>
        <version>6.8.3</version>
    </dependency>

in application properties:

spring.elasticsearch.server=localhost:9200
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300
spring.data.elasticsearch.repositories.enabled=true

Can someone suggest me ,How I can fix it.

1
How do you configure the connection to Elasticsearch? It seems that Spring-Boot autoconfigures a TransportClient that connects to localhost:9300, although you use the rest client.P.J.Meisch
yes..How I can stop thissree
Well, how do you configure your application? Please post the relevant properties.P.J.Meisch
updated the description with pom.xml and propertysree

1 Answers

1
votes

Remove these lines from your configuration:

spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300

These make Spring Boot to configure the transport client.