Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Fix Read timed out in Elasticsearch

I used Elasticsearch-1.1.0 to index tweets. The indexing process is okay. Then I upgraded the version. Now I use Elasticsearch-1.3.2, and I get this message randomly:

Exception happened: Error raised when there was an exception while talking to ES. ConnectionError(HTTPConnectionPool(host='127.0.0.1', port=8001): Read timed out. (read timeout=10)) caused by: ReadTimeoutError(HTTPConnectionPool(host='127.0.0.1', port=8001): Read timed out. (read timeout=10)). 

Snapshot of the randomness:

Happened --33s-- Happened --27s-- Happened --22s-- Happened --10s-- Happened --39s-- Happened --25s-- Happened --36s-- Happened --38s-- Happened --19s-- Happened --09s-- Happened --33s-- Happened --16s-- Happened   --XXs-- = after XX seconds 

Can someone point out on how to fix the Read timed out problem?

Thank you very much.

like image 611
Hendra Bunyamin Avatar asked Sep 18 '14 09:09

Hendra Bunyamin


People also ask

How do I increase Elasticsearch read timeout?

Answer #1: By default, the timeout value is set to 10 secs. If one wants to change the global timeout value, this can be achieved by setting the flag timeout=your-time while creating the object.

What is read timed out error?

From the client side, the “read timed out” error happens if the server is taking longer to respond and send information. This could be due to a slow internet connection, or the host could be offline. From the server side, it happens when the server takes a long time to read data compared to the preset timeout.


1 Answers

Its hard to give a direct answer since the error your seeing might be associated with the client you are using. However a solution might be one of the following:

1.Increase the default timeout Globally when you create the ES client by passing the timeout parameter. Example in Python

es = Elasticsearch(timeout=30) 

2.Set the timeout per request made by the client. Taken from Elasticsearch Python docs below.

# only wait for 1 second, regardless of the client's default es.cluster.health(wait_for_status='yellow', request_timeout=1) 

The above will give the cluster some extra time to respond

like image 50
Skillachie Avatar answered Sep 23 '22 15:09

Skillachie