繁体   English   中英

AWS elasticsearch 服务抛出 Faraday::ConnectionFailed: Failed to open TCP connection to https:80 (getaddrinfo: Name or service not known)

[英]AWS elasticsearch service throws Faraday::ConnectionFailed: Failed to open TCP connection to https:80 (getaddrinfo: Name or service not known)

我目前正在尝试在我的 Rails v 5.1.4 应用程序中配置 AWS 的 elasticsearch 服务。 我正在使用elasticsearch-rails 6.0.0. 我目前遇到的问题是我的 elasticsearch 客户端是如何在我的初始化程序中设置的。 我的一个限制是我不能使用faraday_middleware-aws-signers-v4 gem 来帮助我的 AWS elasticsearch 实例和我的应用程序之间的通信。 我正在尝试仅使用aws-sdk-rails 1.0.1.来执行此操作aws-sdk-rails 1.0.1. 由于此服务器与 elasticsearch 实例位于同一安全组中,因此我假设我不需要传入凭据。

这是我的错误:

Faraday::ConnectionFailed: Failed to open TCP connection to https:80 (getaddrinfo: Name or service not known)
from /usr/local/lib/ruby/2.4.0/net/http.rb:906:in `rescue in block in connect'`

这是我的initializers/elasticsearch.rb

config = {
  hosts: {host: 'https://search-epl-elasticsearch-xxxxxxxxxxxxxxxxxx.us-east-2.es.amazonaws.com', port: '80'},
  transport_options: {
    request: { timeout: 5 }
  }
}
Elasticsearch::Model.client = Elasticsearch::Client.new(config)

我意识到这是几个月后,但似乎您正在使用 https url 配置 elasticsearch 并告诉它使用端口 80 而不是 443。试试这个:

config = {
  url: 'https://search-epl-elasticsearch-xxxxxxxxxxxxxxxxxx.us-east-2.es.amazonaws.com',
  transport_options: {
    request: { timeout: 5 }
  }
}
Elasticsearch::Model.client = Elasticsearch::Client.new(config)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM