Code
using Elastic.Clients.Elasticsearch;
using Elastic.Transport;
using System;
using System.Threading.Tasks;
namespace ESTest
{
internal class Program
{
static void Main(string[] args)
{
var respo = CreateIndex();
// Console.ReadKey();
}
public static async Task CreateIndex()
{
var settings = new ElasticsearchClientSettings(new Uri("http://192.168.1.53:9200/"))
.Authentication(new BasicAuthentication("elastic", "vPM5UsWCwR-oI2ZsFe0k"));
var client = new ElasticsearchClient(settings);
var resopn= await client.Indices.CreateAsync("7778");
}
}
}
Error
# FailureReason: Unrecoverable/Unexpected BadRequest while attempting PUT on http://192.168.1.53:9200/7778
- [1] BadRequest: Node: http://192.168.1.53:9200/ Exception: NullReferenceException Took: 00:00:00.0882637
# Audit exception in step 1 BadRequest:
System.NullReferenceException: 未将对象引用设置到对象的实例。
在 Elastic.Transport.HttpWebRequestInvoker.SetAuthenticationIfNeeded(Endpoint endpoint, RequestData requestData, HttpWebRequest request) 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/TransportClient/HttpWebRequestInvoker.cs:行号 424
在 Elastic.Transport.HttpWebRequestInvoker.CreateHttpWebRequest(Endpoint endpoint, RequestData requestData, PostData postData, Boolean isAsync) 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/TransportClient/HttpWebRequestInvoker.cs:行号 264
在 Elastic.Transport.HttpWebRequestInvoker.<RequestCoreAsync>d__13`1.MoveNext() 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/TransportClient/HttpWebRequestInvoker.cs:行号 88
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 Elastic.Transport.RequestPipeline.<CallProductEndpointCoreAsync>d__43`1.MoveNext() 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/Pipeline/RequestPipeline.cs:行号 198
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
在 Elastic.Transport.DistributedTransport`1.<RequestCoreAsync>d__16`1.MoveNext() 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/DistributedTransport.cs:行号 161
# Inner Exception: 未将对象引用设置到对象的实例。
System.NullReferenceException: 未将对象引用设置到对象的实例。
在 Elastic.Transport.HttpWebRequestInvoker.SetAuthenticationIfNeeded(Endpoint endpoint, RequestData requestData, HttpWebRequest request) 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/TransportClient/HttpWebRequestInvoker.cs:行号 424
在 Elastic.Transport.HttpWebRequestInvoker.CreateHttpWebRequest(Endpoint endpoint, RequestData requestData, PostData postData, Boolean isAsync) 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/TransportClient/HttpWebRequestInvoker.cs:行号 264
在 Elastic.Transport.HttpWebRequestInvoker.<RequestCoreAsync>d__13`1.MoveNext() 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/TransportClient/HttpWebRequestInvoker.cs:行号 88
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 Elastic.Transport.RequestPipeline.<CallProductEndpointCoreAsync>d__43`1.MoveNext() 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/Pipeline/RequestPipeline.cs:行号 198
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
在 Elastic.Transport.DistributedTransport`1.<RequestCoreAsync>d__16`1.MoveNext() 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/DistributedTransport.cs:行号 161
# Exception:
Elastic.Transport.UnexpectedTransportException: 未将对象引用设置到对象的实例。 ---> System.NullReferenceException: 未将对象引用设置到对象的实例。
在 Elastic.Transport.HttpWebRequestInvoker.SetAuthenticationIfNeeded(Endpoint endpoint, RequestData requestData, HttpWebRequest request) 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/TransportClient/HttpWebRequestInvoker.cs:行号 424
在 Elastic.Transport.HttpWebRequestInvoker.CreateHttpWebRequest(Endpoint endpoint, RequestData requestData, PostData postData, Boolean isAsync) 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/TransportClient/HttpWebRequestInvoker.cs:行号 264
在 Elastic.Transport.HttpWebRequestInvoker.<RequestCoreAsync>d__13`1.MoveNext() 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/TransportClient/HttpWebRequestInvoker.cs:行号 88
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 Elastic.Transport.RequestPipeline.<CallProductEndpointCoreAsync>d__43`1.MoveNext() 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/Components/Pipeline/RequestPipeline.cs:行号 198
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
在 Elastic.Transport.DistributedTransport`1.<RequestCoreAsync>d__16`1.MoveNext() 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/DistributedTransport.cs:行号 161
--- 内部异常堆栈跟踪的结尾 ---
在 Elastic.Transport.DistributedTransport`1.ThrowUnexpectedTransportException[TResponse](Exception killerException, List`1 seenExceptions, Endpoint endpoint, TResponse response, IReadOnlyCollection`1 auditTrail) 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/DistributedTransport.cs:行号 283
在 Elastic.Transport.DistributedTransport`1.<RequestCoreAsync>d__16`1.MoveNext() 位置 /home/runner/work/elastic-transport-net/elastic-transport-net/src/Elastic.Transport/DistributedTransport.cs:行号 176
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
在 Elastic.Clients.Elasticsearch.ElasticsearchClient.<>c__DisplayClass865_0`3.<<DoRequestCoreAsync>g__SendRequestWithProductCheckCore|2>d.MoveNext() 位置 /_/src/Elastic.Clients.Elasticsearch/_Shared/Client/ElasticsearchClient.cs:行号 220
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Threading.Tasks.ValueTask`1.get_Result()
在 System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
在 Elastic.Clients.Elasticsearch.ElasticsearchClient.<>c__DisplayClass865_0`3.<<DoRequestCoreAsync>g__SendRequestWithProductCheck|1>d.MoveNext() 位置 /_/src/Elastic.Clients.Elasticsearch/_Shared/Client/ElasticsearchClient.cs:行号 190
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
在 ESTest.Program.<CreateIndex>d__1.MoveNext() 位置 C:\Users\Admin\source\repos\ESTest\ESTest\Program.cs:行号 27
elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
cluster.name: aicss
node.name: node-1
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
enabled: false
keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
cluster.initial_master_nodes: ["ES01"]
http.host: 0.0.0.0