Elasticsearch使用TransportClient索引数据时,服务器报错。java.io.IOException: 远程主机强迫关闭了一个现有的连接
Elasticsearch | 作者 maxzhaobing | 发布于2016年04月22日 | 阅读数:12756
Elasticsearch使用Client索引数据时,数据正常存储服务也不报错。
Elasticsearch使用TransportClient索引数据时,数据能够正常存储但是Elasticsearch 日志中报错:java.io.IOException: 远程主机强迫关闭了一个现有的连接
而且一下就报了14次。
有没有大神帮忙解决下
版本:Elasticsearch-1.7.5
代码:
import static org.elasticsearch.node.NodeBuilder.*;
import static org.elasticsearch.common.xcontent.XContentFactory.*;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.node.Node;
Settings settings = ImmutableSettings.settingsBuilder()
.put("client.transport.sniff", true)
.build();
TransportClient client = new TransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
IndexResponse response = client.prepareIndex("twitter", "tweet", "5")
.setSource(jsonBuilder()
.startObject()
.field("name", "ceshi5")
.endObject()
)
.execute()
.actionGet();
boolean created = response.isCreated();
System.out.println(created);
Elasticsearch使用TransportClient索引数据时,数据能够正常存储但是Elasticsearch 日志中报错:java.io.IOException: 远程主机强迫关闭了一个现有的连接
而且一下就报了14次。
有没有大神帮忙解决下
版本:Elasticsearch-1.7.5
代码:
import static org.elasticsearch.node.NodeBuilder.*;
import static org.elasticsearch.common.xcontent.XContentFactory.*;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.node.Node;
Settings settings = ImmutableSettings.settingsBuilder()
.put("client.transport.sniff", true)
.build();
TransportClient client = new TransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
IndexResponse response = client.prepareIndex("twitter", "tweet", "5")
.setSource(jsonBuilder()
.startObject()
.field("name", "ceshi5")
.endObject()
)
.execute()
.actionGet();
boolean created = response.isCreated();
System.out.println(created);
6 个回复
suwensen - 如影随形
赞同来自:
maxzhaobing
赞同来自:
sp42 - Java,Js
赞同来自:
zayne
赞同来自:
jasonluelastic
赞同来自:
eric930721
赞同来自: