NEST product check call fails every time

Hello! I'm writing a program using .NET 6.0 and NEST 7.17.2 to import a bunch of data into Elasticsearch

But whenever I try to import any data with BulkAll or Index I always run into the same exception

service_1  | Invalid NEST response built from a unsuccessful () low level call on PUT: /elasticsearch/data/_doc/1
service_1  | # Audit trail of this API call:
service_1  |  - [1] ProductCheckOnStartup: Took: 00:00:00.8917764
service_1  |  - [2] ProductCheckFailure: Node: http://proxy/elasticsearch/ Took: 00:00:00.8756822
service_1  | # OriginalException: Elasticsearch.Net.ElasticsearchClientException: The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call. Some functionality may not be compatible if the server is running an unsupported product. Call: Status code 200 from: GET /elasticsearch/
service_1  |  ---> Elasticsearch.Net.PipelineException: The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call. Some functionality may not be compatible if the server is running an unsupported product.
service_1  |    at Elasticsearch.Net.RequestPipeline.ThrowIfTransientProductCheckFailure()
service_1  |    at Elasticsearch.Net.RequestPipeline.Ping(Node node)
service_1  |    at Elasticsearch.Net.Transport`1.Ping(IRequestPipeline pipeline, Node node)
service_1  |    at Elasticsearch.Net.Transport`1.Request[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters)
service_1  |    --- End of inner exception stack trace ---
service_1  | # Request:
service_1  | <Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>
service_1  | # Response:
service_1  | 
service_1  | 

The Elasticsearch node is hosted behind a proxy running in the same Docker environment.
The .NET application is running inside an Alpine linux Docker container.
The following code is what I use to attempt to insert:

var settings = new ConnectionSettings(new Uri("http://proxy:80/elasticsearch"))
                .DisableDirectStreaming()
                .BasicAuthentication("elastic", "DkIedPPSCb")
                .EnableApiVersioningHeader();

var client = new ElasticClient(settings);
Console.WriteLine("Elastic Client connected...");

IEnumerable<Data> DataEnumerator = GetDataEnumerator(data_file);

Console.WriteLine(JsonSerializer.Serialize(DataEnumerator.First()));

var response = client.Index(DataEnumerator.First(), i => i.Index("data"));

Console.WriteLine(response.DebugInformation);
Console.WriteLine(response.Result.ToString());

Some data I've discovered along the way from debugging:
Accept header is always set to application/vnd.elasticsearch+json; compatible-with=0
which is invalid as the server expects either a 8 or a 7, if I overwrite the header using nginx I get the error above, without nginx proxying the request the only thing that changes is the HTTP Status Code, from 200 -> 400 (but same error always).

I've also tried using different versions of NEST (all versions between 7.17.0 -> 7.17.2)

Wireshark screenshot of request + response

I'm simply not sure what I can do at this point to get it working.

Hi @Kristinn_Vikar,

I think this likely is due to the invalid compatible-with value. Looking at your capture, the x-elastic-client-meta header is also reflecting unexpected version for es= and t= which should match the version of the client you have referenced.

I've just had a quick look to see if I can reproduce this. I created a very simple client app which I added to an image which runs it based on the Microsoft mcr.microsoft.com/dotnet/runtime:6.0-alpine image. When I ran it and captured the headers it sent, they appeared as expected:

Internally the client uses reflection to grab version information on the assembly containing the IElasticLowLevelClient type; so essentially:

FileVersionInfo.GetVersionInfo(typeof(IElasticLowLevelClient).GetTypeInfo().Assembly.Location)?.ProductVersion;

This is presumably failing to return a value in your environment. Could you try adding some code to your app code and log out the values to see what you get. I want to first check if for some reason the version information is not retrieved in your environment.

var location = typeof(IElasticLowLevelClient).GetTypeInfo().Assembly.Location;
var version = FileVersionInfo.GetVersionInfo(location)?.ProductVersion;

Console.WriteLine(location); // or send to a logged etc.
Console.WriteLine(version); // or send to a logged etc.

Can you please confirm the base image and label for your client app Docker image. If possible, it would be great to see your Dockerfile for your image.

1 Like

Thank you!
After I saw
typeof(IElasticLowLevelClient).GetTypeInfo().Assembly.Location;
I realized its using its own dll location, I was running with
<PublishSingleFile>true</PublishSingleFile>
which combined it into a single file, removing this line makes the library connect and run properly!

1 Like

You're welcome @Kristinn_Vikar. Good to understand the cause. I've made a note to review the single file publish story and potentially update the docs.

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