-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Elastic.Clients.Elasticsearch version:
8.18.3
8.17.4
Elasticsearch version:
8.18.1
8.17.4
.NET runtime version:
dotnet 8
Operating system version:
windows 11
Description of the problem including expected versus actual behavior:
NullReferenceException being thrown when using client.PingAsnc() with Elastic.Apm reference with an invalid url to simulate DNS failure.
Note: This issue is fixed in elsaticsearch dotnet client 9.05 and above
Steps to reproduce:
using Elastic.Apm;
using Elastic.Clients.Elasticsearch;
using Elastic.Transport;
Console.WriteLine("Begin Testing.");
var user = "elasticuser";
var pwd = "randomepwd";
//NOTE: provide unreachable url to simulate DNS failure
var searchUris = new Uri[] { new Uri("https://localhost2:9200") };
var pool = new StaticNodePool(searchUris);
//var clientSettings = new ElasticsearchClientSettings(pool);
var clientSettings = new ElasticsearchClientSettings(pool);
clientSettings.ServerCertificateValidationCallback((o, cert, chain, errors) => true)
.DefaultFieldNameInferrer(name => name)
.DefaultDisableIdInference()
.EnableDebugMode()
.Authentication(new BasicAuthentication(user, pwd));
var client = new ElasticsearchClient(clientSettings);
// NOTE: below line caused NullReferenceException being thrown with Elastic.Apm 1.32.2 or 1.31.0
// and elastic client 8.17.4 or 8.18.3, 9.0.3, 9.0.4
// Working fine with elastic client 9.0.5, 9.0.6, 9.0.7
var tracer = Agent.Tracer;
var pingResponse = await client.PingAsync().ConfigureAwait(false);
Console.WriteLine($"Is valid response: {pingResponse.IsValidResponse}");
Expected behavior
A clear and concise description of what you expected to happen.
Provide ConnectionSettings
(if relevant):
Provide DebugInformation
(if relevant):
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Elastic.Transport.DistributedTransport1.RequestCoreAsync[TResponse](Boolean isAsync, EndpointPath path, PostData data, Action
1 configureActivity, IRequestConfiguration localConfiguration, CancellationToken cancellationToken)
at Elastic.Clients.Elasticsearch.ElasticsearchClient.<>c__DisplayClass701_03.<<DoRequestCoreAsync>g__SendRequestWithProductCheckCore|2>d.MoveNext() in /_/src/Elastic.Clients.Elasticsearch/_Shared/Client/ElasticsearchClient.cs:line 213 --- End of stack trace from previous location --- at Elastic.Clients.Elasticsearch.ElasticsearchClient.<>c__DisplayClass701_0
3.<g__SendRequestWithProductCheck|1>d.MoveNext() in /_/src/Elastic.Clients.Elasticsearch/_Shared/Client/ElasticsearchClient.cs:line 172
--- End of stack trace from previous location ---
at Program.
at Program.(String[] args)