Sniffer connection issue when ElasticSearch is authenticated

I’ve configured ElasticSearch server with authentication and works, but there are connection issues related to the ElasticSearch Sniffer class:

org.elasticsearch.client.ResponseException: method [GET], host [http://localhost:9200], URI [/_nodes/http?timeout=1000ms], status line [HTTP/1.1 401 Unauthorized]
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/_nodes/http?timeout=1000ms]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"missing authentication credentials for REST request [/_nodes/http?timeout=1000ms]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}
	at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:331)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:301)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:276)
	at org.elasticsearch.client.sniff.ElasticsearchNodesSniffer.sniff(ElasticsearchNodesSniffer.java:106)
	at org.elasticsearch.client.sniff.Sniffer.sniff(Sniffer.java:209)
	at org.elasticsearch.client.sniff.Sniffer$Task.run(Sniffer.java:140)
	at org.elasticsearch.client.sniff.Sniffer$1.run(Sniffer.java:81)

I don’t have any idea about why regular queries work but just the Sniffer fails. It seems that this Sniffer make use of RestClient but ignoring the authentication configuration properties at application.properties:

spring.jpa.properties.hibernate.search.backend.username=elastic
spring.jpa.properties.hibernate.search.backend.password=changeit

Any idea or workaround?

I’m assuming this is the same problem as elasticsearch - How do i stop hibernate search from sniffing the nodes of a non-existent local elastic search server? - Stack Overflow ?

This really is a Spring issue, but I added a bit about that to the reference documentation for the next release: HSEARCH-4551 + HSEARCH-4554 + HSEARCH-4646 + HSEARCH-4653 + HSEARCH-4658 Documentation improvements by yrodiere · Pull Request #3199 · hibernate/hibernate-search · GitHub

And to clarify, there are two Elasticsearch clients and two Sniffers in your application here: Hibernate Search’s and Spring’s. Both need to be configured separately.

Thanks, I was able to avoid this error disabling ElasticSearch autoconfiguration in SpringBoot as recommended in elasticsearch - How do i stop hibernate search from sniffing the nodes of a non-existent local elastic search server? - Stack Overflow.

Quite odd, anyway… :thinking: