弹性搜索和隧道:我可以使用浏览器(google_chrome)连接到elesticsearch,但不能与JAVA api连接 [英] elasticsearch and tunnel : i can connect to elesticsearch using browser(google_chrome) but not with JAVA api
问题描述
我有这个错误:
org.elasticsearch.client.transport.NoNodeAvailableException:没有配置的节点可用
p>我已经尝试在我的环境中重新创建配置,并设法使用Elasticsearch(创建了一个索引)。以下是如何进行的:
public class App
{
public static void main(String [] args)throws Exception
{
设置设置= ImmutableSettings.settingsBuilder()。
put(cluster.name,my-cluster)。build();
TransportClient client = new TransportClient(settings)
.addTransportAddress(
new InetSocketTransportAddress(
localhost,9093));
CreateIndexResponse rs = client.admin()。indexes()。create(new CreateIndexRequest(tunnelingindex))actionGet();
System.out.println(rs.isAcknowledged());
client.close();
}
}
代码创建一个名为 tunnelingindex
如果仍然不适合您,我认为您可能有一个与隧道或弹性搜索无关的问题。
希望我有成功的帮助。
my cluster it's not in the same network, and there is a tunnel between my pc and the server.
i have got this error :
org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available
I have tried to recreate your configuration on my environment and managed to work with Elasticsearch (created an index). Here is how it goes:
- Configure Putty tunneling for Elasticsearch 9300 and 9200 ports
- After configuring you'll need to open the SSH connection and make sure it is connected
- You may look at the SSH event log here is a link on how to do it
The code looks like this
public class App
{
public static void main( String[] args ) throws Exception
{
Settings settings = ImmutableSettings.settingsBuilder().
put("cluster.name", "my-cluster").build();
TransportClient client = new TransportClient(settings)
.addTransportAddress(
new InetSocketTransportAddress(
"localhost", 9093));
CreateIndexResponse rs = client.admin().indices().create(new CreateIndexRequest("tunnelingindex")).actionGet();
System.out.println(rs.isAcknowledged());
client.close();
}
}
The code creates an index named tunnelingindex
If it still do not work for you, I think that you may have an issue which is not related to tunneling or Elasticsearch.
Hope I have managed to help.
这篇关于弹性搜索和隧道:我可以使用浏览器(google_chrome)连接到elesticsearch,但不能与JAVA api连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!