I’m playing around with Elasticsearch_kibana. When I tried to create an index, it raised a timeout error, although I increased request_timeout to 30. Can somebody help me, please? I use elasticsearch-8.11.3 and kibana-8.11.3 on window10.
Here my code:
import os
import sys
import pandas as pd
from elasticsearch import Elasticsearch
def connect_database():
es = None
es = Elasticsearch([{'host': 'localhost', 'port': 9200, 'scheme': 'http'}])
if es.ping():
print("Elastic search connected")
print(es.cluster.health())
else:
print("Connect failed")
return es
es = connect_database()
es.indices.create(index="mydatabasename", ignore=400, request_timeout=30)
and output:
Elastic search connected
{'cluster_name': 'elasticsearch', 'status': 'green', 'timed_out': False, 'number_of_nodes': 1, 'number_of_data_nodes': 1, 'active_primary_shards': 29, 'active_shards': 29, 'relocating_shards': 0, 'initializing_shards': 0, 'unassigned_shards': 0, 'delayed_unassigned_shards': 0, 'number_of_pending_tasks': 13, 'number_of_in_flight_fetch': 0, 'task_max_waiting_in_queue_millis': 3050137, 'active_shards_percent_as_number': 100.0}
---------------------------------------------------------------------------
TimeoutError Traceback (most recent call last)
File ~\AppData\Roaming\Python\Python310\site-packages\urllib3\connectionpool.py:449, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
445 except BaseException as e:
446 # Remove the TypeError from the exception chain in
447 # Python 3 (including for exceptions like SystemExit).
448 # Otherwise it looks like a bug in the code.
--> 449 six.raise_from(e, None)
450 except (SocketTimeout, BaseSSLError, SocketError) as e:
File <string>:3, in raise_from(value, from_value)
File ~\AppData\Roaming\Python\Python310\site-packages\urllib3\connectionpool.py:444, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
443 try:
--> 444 httplib_response = conn.getresponse()
445 except BaseException as e:
446 # Remove the TypeError from the exception chain in
447 # Python 3 (including for exceptions like SystemExit).
448 # Otherwise it looks like a bug in the code.
File c:\Program Files\Python310\lib\http\client.py:1374, in HTTPConnection.getresponse(self)
1373 try:
-> 1374 response.begin()
1375 except ConnectionError:
...
--> 261 raise ConnectionTimeout("TIMEOUT", str(e), e)
262 raise ConnectionError("N/A", str(e), e)
264 # raise warnings if any from the 'Warnings' header.
ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host="localhost", port=9200): Read timed out. (read timeout=30))
Here my elasticsearch.yml:
# Enable security features
xpack.security.enabled: false
xpack.security.enrollment.enabled: false
# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
enabled: false
keystore.path: certs/http.p12
# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
enabled: false
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
# Create a new cluster with the current node only
# Additional nodes can still join the cluster later
cluster.initial_master_nodes: ["MSI"]
# Allow HTTP API connections from anywhere
# Connections are encrypted and require user authentication
http.host: 0.0.0.0
I just ran the default command of elasticseach and kibana and still can access to http://localhost:9200/
and http://localhost:5601/
I fixed rolling back to ES version 7.17.16 and it worked fine. I think this version may require more striction on creating a new index.
How do you have Elasticsearch setup?
ok let me add more to my question a little bit