Search fails with " listener timeout after waiting for [30000] ms"

We have a 10-node cluster having just a few GBs of data. We have 5 indexes (total of 28 primary shards) and replication of 1 for each shard. Last night we deleted 2 indexes and re-ingested data to these indexes. After this, we are seeing following error when we try to read data from any of the indexes : listener timeout after waiting for [30000] ms
at org.elasticsearch.client.RestClient$SyncResponseListener.get( ~[rest-5.2.2.jar:5.2.2]
at org.elasticsearch.client.RestClient.performRequest( ~[rest-5.2.2.jar:5.2.2]
at org.elasticsearch.client.RestClient.performRequest( ~[rest-5.2.2.jar:5.2.2]

I have searched this forum and SO for similar issues, but the suggestions are mainly for long running ingestion or bulk updates which is not applicable to our scenario since we observe this error during search. If I try to run the same query using curl command by logging in to one of the ES nodes, it runs fine without any errors and returns the results.

This is the code we use to create RestClient

public RestClient getElasticServerRestClient(String sourceESServerIp, int sourceESServerPort,
		String sourceESServerProtocol, final String userName, final String password,String resource) {
	try {
		HttpHost elasticCacheHost = new HttpHost(sourceESServerIp, sourceESServerPort, sourceESServerProtocol);
		RestClientBuilder restClientBuilder = RestClient.builder(elasticCacheHost);
		restClientBuilder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
			public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
				int maxConnTotal = cacheConfigurations.getMaxTotalConnections();
				if (maxConnTotal > 0) {
				int maxConnPerRoute = cacheConfigurations.getMaxConnectionsPerRoute();
				if (maxConnPerRoute > 0) {

				if (userName != null && !userName.trim().isEmpty() && password != null && !password.trim().isEmpty()) {
					final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); 
					credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, 
				return httpClientBuilder;

		RestClient elasticServerRestClient =;
		return elasticServerRestClient;
	catch (Throwable t) {
		log.error("Error in getElasticServerRestClient", t);
		return null;

The cluster state is green and no sign of any other issues from logs also. Please share any suggestions on how to identify why it is failing.

Thanks & Regards,

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.