弹性搜索和隧道:我可以使用浏览器(google_chrome)连接到elesticsearch,但不能与JAVA api连接 [英] elasticsearch and tunnel : i can connect to elesticsearch using browser(google_chrome) but not with JAVA api

查看:287
本文介绍了弹性搜索和隧道:我可以使用浏览器(google_chrome)连接到elesticsearch,但不能与JAVA api连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有这个错误:



org.elasticsearch.client.transport.NoNodeAvailableException:没有配置的节点可用

解决方案

p>我已经尝试在我的环境中重新创建配置,并设法使用Elasticsearch(创建了一个索引)。以下是如何进行的:




  • 为Elasticsearch 9300和9200端口配置Putty隧道

  • 您需要打开SSH连接并确保已连接

  • 您可以查看SSH事件日志


代码看起来像这样

  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:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆