需要有关通过Java使用反向代理URL设置Elastic Search的帮助。
在运行于公司专用网络的VM(localhost:9200)中安装了Elastic Search。我们为该网址启用了反向代理。在浏览器中粘贴URL时,工作正常。
https://demo-es.xyz.abc.com
{
"name" : "13abc1","cluster_name" : "elasticsearch","cluster_uuid" : "5u9dqlSBRSmpabcdefghij","version" : {
"number" : "7.8.0","build_flavor" : "default","build_type" : "deb","build_hash" : "12341234.......","build_date" : "2020-6-10T03:35:50.234439Z","build_snapshot" : false,"lucene_version" : "8.5.1","minimum_wire_compatibility_version" : "6.8.0","minimum_index_compatibility_version" : "6.0.0-beta1"
},"tagline" : "You Know,for Search"
}
但是我需要通过Java代码进行连接。我正在使用以下代码进行连接,但接收到连接被拒绝。
public ElasticSearch(String host,int port,String protocol) throws IOException {
client = new RestHighLevelClient(
RestClient.builder(
new HttpHost("demo-es.xyz.abc.com",443)));
}
我也尝试使用它,但是没有用
RestClient.builder(new HttpHost("demo-es.xyz.abc.com",443,"https")));
错误:
org.apache.http.ConnectionClosedException: Connection is closed
at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:813)
[]
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:248)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:235)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1611)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1581)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1551)
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:1067)
at com.presto.banking.util.ElasticSearch.searchRecords(ElasticSearch.java:46)
at com.presto.banking.util.ElasticSearch.main(ElasticSearch.java:76)
Caused by: org.apache.http.ConnectionClosedException: Connection is closed
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.endOfInput(HttpAsyncRequestExecutor.java:356)
at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:261)
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:114)
at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591)
at java.lang.Thread.run(Thread.java:748)
是否存在通过Java Source连接Elastic Search的替代方法?