elasticsearch-java: [es/snapshot.create] Missing [X-Elastic-Product] header

Elasticsearch version (bin/elasticsearch --version): 7.16.2

Plugins installed: []

JVM version (java -version):

openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.21.10)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.21.10, mixed mode, sharing)

OS version (uname -a if on a Unix-like system):

Linux pop-os 5.15.8-76051508-generic #202112141040~1639505278~21.10~0ede46a SMP Tue Dec 14 22:38:29 U x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:

When performing a snapshot using the new Java client, it fails due to missing X-Elastic-Product header sent by Elasticsearch.

Steps to reproduce:

Please include a minimal but complete recreation of the problem, including (e.g.) index creation, mappings, settings, query etc. The easier you make for us to reproduce it, the more likely that somebody will take the time to look at it.

  1. Create an FS repository,
  2. Create a snapshot using the new java client:
final CreateSnapshotRequest request = new CreateSnapshotRequest
  .Builder()
  .repository(repository)
  .snapshot(name)
  .waitForCompletion(waitForCompletion)
  .build();
client.create(request);

Client being used (maven dep):

<elasticsearch.version>7.16.2</elasticsearch.version>

...

      <dependency>
        <groupId>co.elastic.clients</groupId>
        <artifactId>elasticsearch-java</artifactId>
        <version>${elasticsearch.version}</version>
      </dependency>
  1. The code throws an exception.

Provide logs (if relevant):

co.elastic.clients.transport.TransportException: [es/snapshot.create] Missing [X-Elastic-Product] header. Please check that you are connecting to an Elasticsearch instance, and that any networking filters are preserving that header.

	at co.elastic.clients.transport.rest_client.RestClientTransport.checkProductHeader(RestClientTransport.java:340)
	at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:250)
	at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:144)
	at co.elastic.clients.elasticsearch.snapshot.ElasticsearchSnapshotClient.create(ElasticsearchSnapshotClient.java:142)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (11 by maintainers)

Most upvoted comments

I ran into the same exact problem with just a search call against ElasticSearch 6.8. Could you perhaps make this check configurable in the client instead of hard-coding for the snapshot case like you did in the workaround?

Otherwise, is there an older version of the client that does not perform this check that I could use?

@mertkinag please read the compatibiity policy: https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/introduction.html

The Elasticsearch Java client is forward compatible; meaning that the client supports communicating with greater or equal minor versions of Elasticsearch. Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made.

So you cannot use the Java API client with Elasticsearch 6.x. The High Level Rest Client (version 6) works fine though.

@swallez Yes, sorry, I realized after I asked that the client version has to match the server version. Thanks for responding!

Thanks for the additional details. I was able to reproduce it, and this is an issue in Elasticsearch for this endpoint that may also affect some others. We’ll fix Elasticsearch and if necessary add some workarounds in the client library.

Hi,

Elasticsearch is running on my local machine (docker container). The response doesn’t contain the X-Elastic-Product header when debugging the java sdk. There is no proxy / no intermediate. Everything runs on my local computer.

image

Same issue when disabling “gzip compression” on client side:

image

Debugging RestClientTransport:

image

I’m not sure to understand why this header has to be sent by Elasticsearch.