We are caching the created connection, and use ping often to ensure that the connection is still valid and would like it to fail quickly if not so we can create a new one.
With the Java High Level REST Client we can provide RequestOptions allowing us to set a short timeout for the ping.
boolean response = client.ping(myPingRequestOptions);
This was very helpful as you could have different timeouts for searches and pings.
With the new Java API Client it looks like you cannot pass such custom request options and only set timeouts when creating the connection:
Is there anyway to reuse the same connection but set a different timeout for the ping?
This isn't possible at the moment. However there is a workaround:
ping is a very simple API endpoint and it's easy to call it with the low level REST client used to create the Java API client:
RequestOptions options = RequestOptions.DEFAULT.toBuilder()
Request request = new Request("HEAD", "/");
However I'm wondering why the connection would become invalid.
Unfortunately the connection sometimes drops, terminates etc.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.