Read timeout error after setting the request_timeout

Hi ,

I am feteching the data via python script and getting the following error:

elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='hnode07', port=9200): Read timed out. (read timeout=30))

I am using the following command to set the connection

res = es.search(index='event*', doc_type='farm',size=5000,
body={"sort": [{"@timestamp": {"order": "asc"}}],"query": {"match": {"id": id}}},request_timeout=30)

Is your elasticsearch cluster running on the same host and the python client?

I have noted that size param you are asking for but first, what do you see when you increase the timeout param from 30 to 60?

No elastic search cluster is running on different machine and I am running the script from a different machine.

One interesting thing I found it's getting timeout in first 2-3 attempt but after that it's working fine and I am getting the output.

You can see this . First time it failed due to time timeout , second time it was almost near to timeout and third time it resolved within 1-2 seconds. I have highlighted the start and end time of every execution for your reference.

[niraj@sj-niraj ~/ELK]$ date;./run.py --cluster sol 952552;date
Thu Apr 19 19:10:38 PDT 2018

GET http://hnode07:9200/lsbevent*/farm-lsbevent/_search?size=5000 [status:N/A request:60.012s]
Traceback (most recent call last):
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 386, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 382, in _make_request
httplib_response = conn.getresponse()
File "/python/v3.6.1/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/python/v3.6.1/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/python/v3.6.1/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/python/v3.6.1/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/connection/http_urllib3.py", line 147, in perform_request
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/util/retry.py", line 333, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 388, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 308, in _raise_timeout
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='hnode07', port=9200): Read timed out. (read timeout=60)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/connection/http_urllib3.py", line 147, in perform_request
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/util/retry.py", line 333, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 388, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "s/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 308, in _raise_timeout
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='hnode07', port=9200): Read timed out. (read timeout=60)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./bhist", line 23, in
res=elstic_cluster_connection.conn(jobid)
File "/home/niraj/ELK/elstic_cluster_connection.py", line 24, in conn
body={"sort": [{"@timestamp": {"order": "asc"}}],"query": {"match": {"jobid": jobid}}},request_timeout=60)
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/client/utils.py", line 76, in _wrapped
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/client/init.py", line 636, in search
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/transport.py", line 314, in perform_request
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/connection/http_urllib3.py", line 155, in perform_request
elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='hnode07', port=9200): Read timed out. (read timeout=60))
Thu Apr 19 19:11:39 PDT 2018

==============================================================================

[niraj@sj-niraj ~/ELK]$ date ; ./run.py --cluster sol 952552 ; date
Thu Apr 19 19:11:53 PDT 2018

Job<952552>, Job Name <>, User
Sun Mar 25 22:55:01 2018: Starting (Pid 10316);

Summary of time in seconds spent in various states

4506 0 126 0 0 0 4632

Thu Apr 19 19:12:06 PDT 2018
[niraj@sj-niraj ~/ELK]$

=================================================================================
[niraj@sj-niraj ~/ELK]$ date ; ./run.py --cluster sol 952552 ; date
Thu Apr 19 19:15:36 PDT 2018

Job<952552>, Job Name <>, User
Sun Mar 25 22:55:01 2018: Starting (Pid 10316);

Summary of time in seconds spent in various states

4506 0 126 0 0 0 4632

Thu Apr 19 19:15:37 PDT 2018

I increased the request_timeout from 30 to 60 as well but the issue is same as said above

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