'Status code unknown Error at IndexDocument()

I want to inject a data set using C# and elastic + kibana version 8.x. On console at Kibana it works fine. The dataset is not saved at elastic and at the C# code at the indexResponse object I get the error message (the full message you find on the end of this post):

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 unknown from: GET /

I checked the net and find a article about this exception and tried to implement the solution at the setting (I add CertificateFingerprint, BasicAuthentication and EnableApiVersioningHeader). But it does not solve the exception.

What could cause and what could solve that error?

Thanks, Frank

public class Manager
{
    ElasticClient client;
    public Manager()
    {
        var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
        ConnectionSettings settings = new ConnectionSettings(pool)
            .CertificateFingerprint("94:75:CE:4F:EB:05:32:83:40:B8:18:BB:79:01:7B:E0:F0:B6:C3:01:57:DB:4D:F5:D8:B8:A6:BA:BD:6D:C5:C4")
            .BasicAuthentication("elastic", "...")
            .EnableApiVersioningHeader()
            .DefaultIndex("test"); 
        client = new ElasticClient(settings);
    }

    public bool injectData()
    {
        Person person = new Person
        {
            name = "Anna",
            age = 29,
            address = "Beethovenweg 8, 99817 Eisenach"
        };

        IndexResponse indexResponse = client.IndexDocument(person);
        return indexResponse != null;
    }
}

at console:

POST /test/_doc/
{
  "name": "Oliver",
  "age": 29,
  "address": "Germany"
}
GET /test/_search

answer to GET command:

{
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "test",
        "_id" : "cBd_mYABTQckRFudSyBa",
        "_score" : 1.0,
        "_source" : {
          "name" : "Oliver",
          "age" : 29,
          "address" : "Germany"
        }
      }
    ]
  }
}

full error message:

Invalid NEST response built from a unsuccessful () low level call on POST: /test/_doc Audit trail of this API call:

  • [1] ProductCheckOnStartup: Took: 00:00:00.4390244
  • [2] ProductCheckFailure: Node: http://localhost:9200/ Took: 00:00:00.2774005 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 unknown from: GET / ---> 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. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: The response ended prematurely. at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Elasticsearch.Net.HttpConnection.Request[TResponse](RequestData requestData) --- End of inner exception stack trace --- at Elasticsearch.Net.RequestPipeline.ThrowIfTransientProductCheckFailure() at Elasticsearch.Net.RequestPipeline.Ping(Node node) at Elasticsearch.Net.Transport1.Ping(IRequestPipeline pipeline, Node node) at Elasticsearch.Net.Transport1.Request[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters) --- End of inner exception stack trace --- Request: <Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.> Response: <Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source