使用SniffingConnectionPool时出现2.4.6错误
本文关键字:错误 SniffingConnectionPool 使用 | 更新日期: 2023-09-27 18:16:45
没有SniffingConnectionPool似乎工作。
var settings2 = new ConnectionSettings(new Uri(elasticSearchUri))
_elasticClient = new ElasticClient(settings2);
但使用SniffingConnectionPool在ConnectionSettings下面:
var settings2 = new ConnectionSettings(new SniffingConnectionPool(new[] { new Uri(elasticSearchUri) }))
.DefaultIndex("myindex")
.DisableDirectStreaming(true);
导致以下错误:"嗅探集群状态失败。"
Splunk日志
Unable to import data to ElasticSearch - Failed sniffing cluster state. PipelineException Project.ScheduledJobService LOCAL ERROR
Unable to import data to ElasticSearch - One or more errors occurred. AggregateException Project.ScheduledJobService LOCAL ERROR
Unable to import data to ElasticSearch - Object reference not set to an instance of an object.
NullReferenceException Project.ScheduledJobService
全面跟踪:
at Elasticsearch.Net.RequestPipeline.Sniff() in C:'Users'russ'source'elasticsearch-net-2.x'src'Elasticsearch.Net'Transport'Pipeline'RequestPipeline.cs:line 358
at Elasticsearch.Net.RequestPipeline.FirstPoolUsage(SemaphoreSlim semaphore) in C:'Users'russ'source'elasticsearch-net-2.x'src'Elasticsearch.Net'Transport'Pipeline'RequestPipeline.cs:line 143
at Elasticsearch.Net.Transport`1.Request[TReturn](HttpMethod method, String path, PostData`1 data, IRequestParameters requestParameters) in C:'Users'russ'source'elasticsearch-net-2.x'src'Elasticsearch.Net'Transport'Transport.cs:line 53
at Elasticsearch.Net.ElasticLowLevelClient.DoRequest[T](HttpMethod method, String path, PostData`1 data, IRequestParameters requestParameters) in C:'Users'russ'source'elasticsearch-net-2.x'src'Elasticsearch.Net'ElasticLowLevelClient.cs:line 58
at Elasticsearch.Net.ElasticLowLevelClient.Bulk[T](PostData`1 body, Func`2 requestParameters) in C:'Users'russ'source'elasticsearch-net-2.x'src'Elasticsearch.Net'ElasticLowLevelClient.Generated.cs:line 32
at Nest.LowLevelDispatch.BulkDispatch[T](IRequest`1 p, PostData`1 body) in C:'Users'russ'source'elasticsearch-net-2.x'src'Nest'_Generated'_LowLevelDispatch.generated.cs:line 26
at Nest.ElasticClient.Nest.IHighLevelToLowLevelDispatcher.Dispatch[TRequest,TQueryString,TResponse](TRequest request, Func`3 responseGenerator, Func`3 dispatch) in C:'Users'russ'source'elasticsearch-net-2.x'src'Nest'ElasticClient.cs:line 56
at Nest.ElasticClient.Nest.IHighLevelToLowLevelDispatcher.Dispatch[TRequest,TQueryString,TResponse](TRequest request, Func`3 dispatch) in C:'Users'russ'source'elasticsearch-net-2.x'src'Nest'ElasticClient.cs:line 46
at Nest.ElasticClient.Bulk(IBulkRequest request) in C:'Users'russ'source'elasticsearch-net-2.x'src'Nest'Document'Multiple'Bulk'ElasticClient-Bulk.cs:line 32
at Project.Core.Services.ElasticSearchService.IndexMultiple(IEnumerable`1 documents)
at Project.ScheduledJobService.Jobs.ElasticSearch.ElasticSearchTrackedChangesDataImportJob.Execute() in C:'Users'Martynas.Valaika'Code'Project'Main'Source'Project'Project.ScheduledJobService'Jobs'Elasticsearch'ElasticSearchTrackedChangesDataImportJob.cs:line 35
显然在ES 5.0中有一个bug。将SniffingConnectionPool替换为SingleNodeConnectionPool应该可以完成这项工作。
var pool = new SingleNodeConnectionPool(new Uri(uri));
var settings = new ConnectionSettings(pool, connectionSettings => new MyJsonNetSerializer(connectionSettings))
.DefaultIndex("seetickets_search_results")
.DisableDirectStreaming();
_elasticClient = new ElasticClient(settings);