[英]Resetting indexes with ruflin/elastica throws HttpException on heroku
我在帶有FOSElasticaBundle的Symfony項目中使用elasticsearch ,這需要ruflin / elastica客戶端。 為了創建索引,我使用FOSElasticaBundle 文檔中建議的命令 ,並且在本地計算機上一切正常。
當我將項目部署到heroku時,同一命令失敗並引發以下錯誤:
elastica.ERROR: Elastica Request Failure {"exception":"[object] (Elastica\\Exception\\Connection\\HttpException(code: 0): Couldn't resolve host at /app/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php:186)","request":{"path":"index_name/","method":"DELETE","data":[],"query":[],"connection":{"config":{"headers":[],"curl":[]},"host":"https://username:password@host","port":"443","logger":"fos_elastica.logger","compression":false,"retryOnConflict":0,"enabled":false}},"retry":false}
這似乎強調了與Elasticsearch主機的連接問題。 奇怪的是,當我嘗試從heroku機器手動連接到該主機時,一切似乎都工作正常。
執行:
curl -X GET host:port/
給我這個回應:
{
"name" : "Alex Power",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "2.4.0",
"build_hash" : "079e104a99267f24d3689297eb16466170b00ebc",
"build_timestamp" : "2016-10-04T20:50:33Z",
"build_snapshot" : false,
"lucene_version" : "5.5.2"
},
"tagline" : "You Know, for Search"
}
在heroku 上 ,我使用bonsai附加組件 ,但我也嘗試使用AWS elasticsearch服務,以及具有不同版本捆綁包和ruflin / elastica客戶端的所有組件。
重現問題:主機始終可以正常工作,但是ruflin客戶端似乎無法與之聯系。
我唯一能想到的是捆綁軟件的配置錯誤,但是我遵循了文檔中的每個步驟,因此我不知道在哪里尋找,此刻我感到迷茫。
編輯 :我只是將項目設置為在本地的docker容器中運行,並在日志中看到以下錯誤:
[2017-04-08 09:45:00] request.CRITICAL: Uncaught PHP Exception Elastica\\Exception\\Connection\\HttpException: "Couldn't connect to host, Elasticsearch down?" at /var/www/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php line 180 {"exception":"[object] (Elastica\\\\Exception\\\\Connection\\\\HttpException(code: 0): Couldn't connect to host, Elasticsearch down? at /var/www/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php:180)"} []
我一直認為這只是一個配置問題,因為我檢查了curl並且elasticsearch正常運行。
我使用以下配置解決了這個問題:
clients: default: host: **** port: **** transport: Https headers: Authorization: "Basic ************"
授予授權令牌的位置:
echo -n "user:password" | base64
您的配置是什么樣的? 可能是HTTP身份驗證搞砸了。 該文檔建議使用類似這樣的東西:
# app/config/config.yml
fos_elastica:
clients:
default:
host: your-bonsai-cluster.some-region.bonsai.io
port: 443
username: 'a1b2c3d4'
password: 'e5f6g7h8'
盆景還支持通過端口9200和端口80進行連接。使用端口80可以避免SSL錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.