【问题标题】:AWS elasticsearch service throws Faraday::ConnectionFailed: Failed to open TCP connection to https:80 (getaddrinfo: Name or service not known)AWS elasticsearch 服务抛出 Faraday::ConnectionFailed: Failed to open TCP connection to https:80 (getaddrinfo: Name or service not known)
【发布时间】:2019-04-09 06:23:36
【问题描述】:

我目前正在尝试在我的 Rails v 5.1.4 应用程序中配置 AWS 的 elasticsearch 服务。我正在使用elasticsearch-rails 6.0.0. 我目前遇到的问题是我的弹性搜索客户端是如何在我的初始化程序中设置的。我的一个限制是我不能使用 faraday_middleware-aws-signers-v4 gem 来帮助我的 AWS elastisearch 实例和我的应用程序之间的通信。我正在尝试仅使用 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)

【问题讨论】:

    标签: ruby-on-rails amazon-web-services elasticsearch


    【解决方案1】:

    我意识到几个月后,但您似乎正在使用 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)
    

    【讨论】:

      猜你喜欢
      • 2014-03-22
      • 2021-08-07
      • 1970-01-01
      • 2019-10-22
      • 1970-01-01
      • 2012-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多