Reputation: 45
I am creating a Elasticsearch Connection with Java API. I am using TransportConnection and I need to set the timeout for the connection.
I haven't configured any property and the connect takes three minutes to give me a timeout.
Anybody know if any property exists to set the value of timeout?
Thaks.
Upvotes: 3
Views: 5883
Reputation: 686
Use the code below to update the TransportClient's connection time out value:
Settings.builder().put("transport.tcp.connect_timeout", "240s")
The Complete TransportClient code:
Settings settings = Settings.builder()
.put("cluster.name", "elasticsearch")
.put("client.transport.sniff", true)
.put("transport.tcp.connect_timeout", "240s")
.build();
Client transportClient = new PreBuiltTransportClient(settings)
.addTransportAddresses(
new TransportAddress("127.0.0.1"), "9300"));
Important: Each Elasticsearch version has different config key. You can read this document to learn about other settings you can change:
www.elastic.co/guide/en/elasticsearch/reference/6.4/modules-transport.html
If you are using AWS Elasticsearch, check the load balancer time out settings.
docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-idle-timeout.html
Upvotes: 1
Reputation: 2360
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", cluster_name).put("client.transport.ping_timeout", "30s").build();
TransportClient transport = new TransportClient(settings);
See also the following from ES documentation page:
Upvotes: 9