algolia / algoliasearch-rails

AlgoliaSearch integration to your favorite ORM
MIT License
410 stars 118 forks source link

Algolia::AlgoliaProtocolError with rspec #252

Open mmhan opened 7 years ago

mmhan commented 7 years ago

I started receiving Algolia::AlgoliaProtocolError after upgrading from 1.17.0 to 1.19.1. I have tested with 1.18.0 and it works.

Full stack trace is below.

Failure/Error: @listing = FactoryGirl.create :used_car_listing, user_id: another_user.id

 Algolia::AlgoliaProtocolError:
   Cannot reach any host: getaddrinfo: nodename nor servname provided, or not known (XXX.algolia.net:443), getaddrinfo: nodename nor servname provided, or not known (XXX-3.algolianet.com:443), getaddrinfo: nodename nor servname provided, or not known (XXX-1.algolianet.com:443), getaddrinfo: nodename nor servname provided, or not known (XXX-2.algolianet.com:443)
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-1.12.7/lib/algolia/client.rb:365:in `request'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-1.12.7/lib/algolia/client.rb:377:in `put'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-1.12.7/lib/algolia/index.rb:431:in `set_settings'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-rails-1.19.1/lib/algoliasearch-rails.rb:292:in `block (3 levels) in <class:SafeIndex>'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-rails-1.19.1/lib/algoliasearch-rails.rb:327:in `log_or_throw'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-rails-1.19.1/lib/algoliasearch-rails.rb:291:in `block (2 levels) in <class:SafeIndex>'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-rails-1.19.1/lib/algoliasearch-rails.rb:750:in `algolia_ensure_init'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-rails-1.19.1/lib/algoliasearch-rails.rb:552:in `block in algolia_index!'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-rails-1.19.1/lib/algoliasearch-rails.rb:549:in `each'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-rails-1.19.1/lib/algoliasearch-rails.rb:549:in `algolia_index!'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-rails-1.19.1/lib/algoliasearch-rails.rb:893:in `algolia_index!'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-rails-1.19.1/lib/algoliasearch-rails.rb:912:in `algolia_enqueue_index!'
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/algoliasearch-rails-1.19.1/lib/algoliasearch-rails.rb:942:in `algolia_perform_index_tasks'
 # ### REMOVED FOR BREVITY
 # /Users/****/.rvm/gems/ruby-2.1.10@****/gems/factory_girl-4.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
 # ./spec/controllers/api/v1/images_controller_spec.rb:10:in `block (3 levels) in <top (required)>'
redox commented 7 years ago

I started receiving Algolia::AlgoliaProtocolError after upgrading from 1.17.0 to 1.19.1. I have tested with 1.18.0 and it works.

Did you anonymise the logs by replacing your appid with XXX? Otherwise, it looks like your application id is not well configured.

Could you try to ping <Your application ID>.algolia.net to check if it resolves well? Looks like the DNS resolution is behind; maybe you tried "too quickly" after signup and now your ISP cached a wrong DNS record?

mmhan commented 7 years ago

"XXX" is the app id I left in for test environment. Am I suppose to put actual APP ID for testing environment as well? It used to work as if in earlier versions since I explicitly declared not to do any indexing in test environment.

redox commented 7 years ago

t used to work as if in earlier versions since I explicitly declared not to do any indexing in test environment.

Could you share with us how do define that?

mmhan commented 7 years ago

I simply used

algoliasearch per_environment: true, disable_indexing: Rails.env.test?

And also I have Figaro gem that adds environment variables.