ElasticSearch常见问题3:elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by
1.问题描述错误日志:elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='192.168.56.100', port=9200): Read timed out. (read timeout=10))2.原因分析Elas
·
1.问题描述
错误日志:
elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='192.168.56.100', port=9200): Read timed out. (read timeout=10))
2.原因分析
ElasticSearch正常运行,在没有特别设置的情况下,timeout 的值是10s。
3.解决方法
普遍情况下有两种解决办法,推荐第1种,本人亲自在自己的环境中试过第二种,也是OK的。
方法一:在请求指令中设置过期时间,例如以下这种方式:
es.search(index="my_index",
doc_type="document",
body=get_req_body(),
request_timeout=30)
方法二:在建立连接的请求URL中设置,例如以下这种方式:(本人是使用Python脚本向ElasticSearch中写入数据,这样设置OK)
es = Elasticsearch([{'host': HOST_ADDRESS, 'port': THE_PORT}], timeout=30)
或
es = Elasticsearch([{'host': HOST_ADDRESS, 'port': THE_PORT}], timeout=30, max_retries=10, retry_on_timeout=True)
参考博文:
更多推荐
已为社区贡献4条内容
所有评论(0)