使用C#中的SniffingConnectionPool连接ES群集时出现以下错误。
解析值时遇到意外的字符:[。 Path' nodes.ZfZk0Y0PQWqg_dkfJZ9DSg.settings [' discovery.zen.ping.unicast.hosts']',第1行,第439位。
它与JSON解析明显相关,但我不知道如何解决这个问题。任何帮助将受到高度赞赏
以下是我配置群集的方式:
Master Node Config:
cluster.name: elasticsearch_marvel
node.name: "Wolverine"
node.master: true
node.data: true
network.host: 192.168.1.9
discovery.zen.ping.unicast.hosts: ["192.168.1.10:9300"]
discovery.zen.minimum_master_nodes: 1
Data Node Config:
cluster.name: elasticsearch_marvel
node.name: "Deadpool"
node.master: false
node.data: true
network.host: 192.168.1.10
discovery.zen.ping.unicast.hosts: ["192.168.1.9:9300"]
discovery.zen.minimum_master_nodes: 1
以下是我尝试连接群集的方法:
public ElasticClient CreateClient(IEnumerable<Uri> uris)
{
var connectionPool = new SniffingConnectionPool(uris);
var settings = new ConnectionSettings(connectionPool);
var client = new ElasticClient(settings);
return client;
}
public bool TestConnection()
{
try
{
var uris = new List<Uri>();
uris.Add(new Uri("http://192.168.1.9:9200/"));
uris.Add(new Uri("http://192.168.1.10:9200/"));
var client = CreateClient(uris);
var response = client.Ping();
return response.IsValid;
}
catch (Exception ex)
{
//Unexpected character encountered while parsing value: [. Path 'nodes.ZfZk0Y0PQWqg_dkfJZ9DSg.settings['discovery.zen.ping.unicast.hosts']', line 1, position 439.
}
}