无法获取aws elasticsearch的索引列表

2024-06-16 10:29:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个python脚本:

from requests_aws4auth import AWS4Auth
from elasticsearch import Elasticsearch, RequestsHttpConnection

session = boto3.session.Session()
credentials = session.get_credentials()
awsauth = AWS4Auth(credentials.access_key,
         credentials.secret_key,
         session.region_name, 'es',
         session_token=credentials.token)



es_client = Elasticsearch(
                        "vpc-mydomain-elasticsearch-xxxxxxxxx.region.es.amazonaws.com:9200",
                        http_auth=awsauth,
                        use_ssl=False,
                        verify_certs=False,
                        connection_class=RequestsHttpConnection)

print(es_client.info())

运行脚本时,出现以下错误:

    raise ConnectionTimeout('TIMEOUT', str(e), e)
elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeout(HTTPConnectionPool(host='10.0.2.2', port=3128): Read timed out. (read timeout=10))

群集的安全组已为0.0.0.0/0打开端口9200。 (10.0.2.2是我的流浪机器的ip地址,端口3128是cntlm的监听端口) 如何得到这份工作?你知道吗

编辑

我也试过,但没用:

 curl -XGET https://vpc-mydomain-elasticsearch-xxxxxxxxx.region.es.amazonaws.com:9200/_cat/indices?v
curl: (56) Received HTTP code 403 from proxy after CONNECT

Tags: 端口keyfromimport脚本essessionelasticsearch
1条回答
网友
1楼 · 发布于 2024-06-16 10:29:22

请尝试以下解决方案:

  • 将默认超时10秒更改为请求\u timeout=n,其中n可以是大于10的数字,最好是30。如果错误仍然存在,则增加。你知道吗
  • 检查你的配置/弹性搜索.yml以确保http.proxy代理变量指向正确的地址。你知道吗
  • 尝试将端口从9200更改为443。你知道吗
  • 将use\u ssl更改为True。你知道吗

希望这有帮助。你知道吗

相关问题 更多 >