Elasticsearch-rails: typhoeus undefined method `connect_timeout=' for #<Typhoeus::Request:0x007fc43c4e8128>

Created on 1 Apr 2015  路  6Comments  路  Source: elastic/elasticsearch-rails

gem 'typhoeus'
undefined method `connect_timeout=' for #Typhoeus::Request:0x007fc43c4e8128

config = {
host: Settings.elasticsearch_servers,
transport_options: {
request: { timeout: 5 }
},
}

Elasticsearch::Model.client = Elasticsearch::Client.new(config)

Most helpful comment

FYI: for now i just put

require 'typhoeus'
require 'typhoeus/adapters/faraday'

in a rails initializer to override the default class.

All 6 comments

I've found lostisland/faraday#366 and https://github.com/lostisland/faraday#331, would you be able to debug it a little bit on new typhoeus and faraday versions?

This is the code I'm able to replicate the error with:

require 'typhoeus' 
require 'elasticsearch'

config = { host: 'localhost:9200', transport_options: { request: { timeout: 5 } } }

client = Elasticsearch::Client.new(config);
# => #<Elasticsearch::Transport::Client:0x007ff6c09e34a0

client.info
# NoMethodError: undefined method `connect_timeout=' for #<Typhoeus::Request:0x007fcc656a6a88>

Same problem here. Any ideas why?

Any luck with this? I think the issue might be https://github.com/lostisland/faraday/issues/608 where typhoeus ships with an updated adapter for faraday and the default adapter bundled with faraday is stale.

FYI: for now i just put

require 'typhoeus'
require 'typhoeus/adapters/faraday'

in a rails initializer to override the default class.

I've tested the aboved-mentioned code and have encountered no error.

```ruby
2.5.1 :014 > require 'typhoeus'
=> true
2.5.1 :014 > require 'elasticsearch'
=> false
2.5.1 :015 >
2.5.1 :016 > config = { host: 'localhost:9200', transport_options: { request: { timeout: 5 } } }
=> {:host=>"localhost:9200", :transport_options=>{:request=>{:timeout=>5}}}
2.5.1 :017 >
2.5.1 :018 > client = Elasticsearch::Client.new(config);
=> #Faraday:0x00007ff2432cdb60 @state_mutex=#, @hosts=[{:host=>"localhost", :port=>9200, :protocol=>"http"}], @options={:host=>"localhost:9200", :transport_options=>{:request=>{:timeout=>5}}, :logger=>nil, :tracer=>nil, :reload_connections=>false, :retry_on_failure=>false, :reload_on_failure=>false, :randomize_hosts=>false, :http=>{:user=>nil, :password=>nil}, :retry_on_status=>[]}, @block=#, @compression=false, @user_agent="elasticsearch-ruby/7.2.0 (RUBY_VERSION: 2.5.1; darwin x86_64; Faraday v0.15.4)", @connections=#ollection:0x00007ff2432d0248 @connections=[#, @ssl=#, @manual_proxy=false, @proxy=nil, @temp_proxy=nil>, @options={:resurrect_timeout=>60}, @state_mutex=#, @dead=false, @failures=0>], @selector=#oundRobin:0x00007ff2432d01d0 @connections=#, @current=nil>>, @serializer=#MultiJson:0x00007ff2432d0180 @transport=#Sniffer:0x00007ff2432d0158 @transport=#, @counter=0, @counter_mtx=#, @last_request_at=2019-07-19 15:51:06 +0200, @reload_connections=false, @reload_after=10000, @resurrect_after=60, @max_retries=3, @retry_on_status=[]>>
2.5.1 :019 > client.info
=> {"name"=>"kjYMuDR", "cluster_name"=>"elasticsearch", "cluster_uuid"=>"4pWKrUkFQJGDrgCv_UUrRA", "version"=>{"number"=>"6.4.2", "build_flavor"=>"default", "build_type"=>"tar", "build_hash"=>"04711c2", "build_date"=>"2018-09-26T13:34:09.098244Z", "build_snapshot"=>false, "lucene_version"=>"7.4.0", "minimum_wire_compatibility_version"=>"5.6.0", "minimum_index_compatibility_version"=>"5.0.0"}, "tagline"=>"You Know, for Search"}

Was this page helpful?
0 / 5 - 0 ratings