Elasticsearch.Net.ElasticsearchClientException: BulkAll halted after failed product check

Unhandled exception. Elasticsearch.Net.ElasticsearchClientException: BulkAll halted after failed product check
   at Nest.BlockingSubscribeExtensions.WaitOnObservable[TObservable,TObserve,TObserver](TObservable observable, TimeSpan maximumRunTime, Func`3 factory)
   at Nest.BlockingSubscribeExtensions.Wait[T](BulkAllObservable`1 observable, TimeSpan maximumRunTime, Action`1 onNext)

I am getting this exception while trying to index a CSV to 3 node cluster.

here is my Code

using System;
using Elasticsearch.Net;
using Nest;
using Kuch_b;
using System.Security.Cryptography.X509Certificates;

namespace elasticsearch_client_example
{
    internal class Testing
    {
        private const string Index_name = "data-v1";
        private static async Task Main(string[] args)
    {
        var cert = new X509Certificate(@"PATH TO ca.pem FILE");
            var uris = Enumerable.Range(9200, 1).Select(port => new Uri($"https://<VM IP>:{port}"));
            var connectionPool = new StaticConnectionPool(uris);
            var settings = new ConnectionSettings(connectionPool)
                .BasicAuthentication("USER_NAME_FOR_ELASTIC", "PASSWORD_FOR_ELASTIC")
               .EnableApiVersioningHeader()
            .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");
            var client1 = new ElasticClient(settings);
            var existResponse = await client1.Indices.ExistsAsync(Index_name);
            if(!existResponse.Exists)
            {
                var createResponse = await client1.Indices.CreateAsync(Index_name, c => c 
                .Map(m => m.AutoMap<grades>()
                .Properties<grades>( p => p.Keyword(k => k.Name(s => s.sSN)))
                )
                .Settings( s => s.NumberOfShards(4).NumberOfReplicas(1)));
                try {
                    if (!createResponse.IsValid && !createResponse.Acknowledged)
                        Console.WriteLine("I am working dude");
                }
                catch (Exception ex )
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            var bulkAll = client1.BulkAll(Read_Data(), r => r
            .Index(Index_name)
            .BackOffRetries(4)
            .BackOffTime("30s")
            .MaxDegreeOfParallelism(4)
            .Size(10));
            bulkAll.Wait(TimeSpan.FromMinutes(10), r => Console.WriteLine("HELLO "));
        }
        public static IEnumerable<grades>Read_Data()
        {
            var file = new StreamReader(@"PATH TO grades.csv");
            string line;
           
            while ((line = file.ReadLine())  != null)
            {
                Console.WriteLine(line);
                yield return new grades(line);
            }
        }
    }

CSV model Class:

public class grades
{
    public string last { get; set; }
    public string first { get; set; }
    public string sSN { get; set; }
    public string g_rade { get; set; }

    public grades(string dataline)
    {
        var columns = dataline.Split(',', StringSplitOptions.TrimEntries);
        last = columns[0];
        first = columns[1];
        sSN = columns[2];
        g_rade = columns[3];
    }
}

Elasticsearch8.2
Nest Version:7.17.4
Any Help will be much Appreciated:

Hi, @dawood_ahmad,

The code looks valid at first glance. This exception can sometimes be misleading and occur when the client cannot communicate with the server due to TLS misconfiguration. Are you sure that the certificate fingerprint matches the value from the Elasticsearch server? A secondary possibility is if you run through a proxy that may strip headers from the server response. We rely on the presence of a header to validate the server.

What is curious is that it appears you call to ExistsAsync is succeeding via the same client instance. The product check should only occur on the first request. Can you try enabling debug mode on the settings with .EnableDebugMode() and then capture the DebugInformation from the ExistsAsync response? The audit trail in particular could be helpful there.

To rule out TLS, you could temporarily replace the CertificateFingerprint configuration with .ServerCertificateValidationCallback((a,b,c,d) => true) which trusts any certificate. Of course, this should not be used in production. If the bulk request succeeds with the validation callback applied, it suggests an issue with the fingerprint.

1 Like

there was a issue with fingerprint ...You are awesome :revolving_hearts:

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