我嘗試ping我Elasticsearch實例(通過盆景部署在Heroku上添加上)。我按照他們的指引,並嘗試對我的計算機上執行以下代碼:Accesing elasticsearch在Heroku盆景從我的電腦
from elasticsearch import Elasticsearch
from settings import BONSAI_URL
import re, logging
# Log transport details (optional):
logging.basicConfig(level=logging.INFO)
# Parse the auth and host from env:
bonsai = BONSAI_URL
print(bonsai)
auth = re.search('https\:\/\/(.*)\@', bonsai).group(1).split(':')
host = bonsai.replace('https://%s:%[email protected]' % (auth[0], auth[1]), '')
# Connect to cluster over SSL using auth for best security:
es_header = [{
'host': host,
'port': 443,
'use_ssl': True,
'http_auth': (auth[0],auth[1])
}]
# Instantiate the new Elasticsearch connection:
es = Elasticsearch(es_header)
# Verify that Python can talk to Bonsai (optional):
es.ping()
我已經得到了以下錯誤消息:
elasticsearch.exceptions.ImproperlyConfigured: Root certificates are missing for certificate validation. Either pass them in using the ca_certs parameter or install certifi to use it automatically.
我認爲這是錯誤的事實來,我沒有一個HTTPS證書,所以我用HTTP,通過刪除URL和正則表達式的s
和切換use_ssl
爲False,但我得到了以下錯誤:
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
如何將我的電腦中的數據插入到Heroku的elasticsearch中?