lrpinheiro
lrpinheiro

Reputation: 91

Can't connect to mongodb 3.4 using mongoid 3.1.0

I'm trying to connect to a mongodb hosted on MLab but the authentication is failing.

When I start my rails app I get the error:

Moped::Errors::AuthenticationFailure: The operation: #<Moped::Protocol::Commands::Authenticate
@length=168
@request_id=3
@response_to=0
@op_code=2004
@flags=[]
@full_collection_name="heroku_vjmpxxzn.$cmd"
@skip=0
@limit=-1
@selector={:authenticate=>1, :user=>"heroku_vjmpxxzn", :nonce=>"9a254f9ab71432e4", :key=>"79a149a6651d6e8234e6d45718eff7f0"}
@fields=nil>
failed with error 18: "auth failed"

I already tried to update the mongoid version, but if I do that I'll need to update a lot of other gems and it will consume a big time.

That is my mongoid.yml production config.

production:
  sessions:
    default:
      database: <database>
      username: <user>
      password: <pass>
      hosts:
        - ds333748-a0.mlab.com:33748
        - ds333748-a1.mlab.com:33748
      options:
          consistency: :strong
          skip_version_check: true
          safe: true

I'm using:

Gemfile

source 'https://rubygems.org'

ruby "2.3.8"

gem 'rails', '3.2.22.5'
gem 'rest-client'
gem 'bundler', '1.15.2'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

# Gems used only for assets and not required
# in production environments by default.

gem 'sass-rails',   '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem "cpf_cnpj"
gem "savon"

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'uglifier', '>= 1.0.3'
gem 'adminlte2-rails'
gem 'jquery-rails'
gem 'will_paginate_mongoid'
gem "mongo_session_store-rails3"
gem 'geocoder', '1.3.3'
gem 'test-unit'
gem 'nokogiri'
gem 'sprockets', '~> 2'
gem  "httparty", '0.13.3'

gem 'mongoid-geospatial'
gem 'credit_card_validations'
gem "chartkick"
gem "time_difference"
gem 'newrelic_rpm'
gem 'dropzonejs-rails'
gem 'mongoid_auto_increment', :git => 'git://github.com/teriyakisan/mongoid_auto_increment.git'
gem 'parse-ruby-client', git: 'https://github.com/adelevie/parse-ruby-client.git', ref: '98596a04dfc30295c1d078c58c31b4cea299e8ca'

gem 'websocket-rails', github: 'moaa/websocket-rails', branch: 'threadsocket-rails'
gem 'websocket-rails-js', github: 'websocket-rails/websocket-rails-js', branch: 'sub_protocols'
gem 'faye-websocket', '0.10.0'

gem 'momentjs-rails'

gem "pagarme"
gem "mongoid", ">= 3.1.0"
gem "paperclip", ' 3.1.1'
gem "mongoid-paperclip", :require => "mongoid_paperclip"
gem 'aws-sdk', '< 3.0'
gem "google-api-client"

gem "cucumber-rails", ">= 1.3.0", :group => :test, :require => false
gem 'apipie-rails'
gem "devise", ">= 2.2.3"
gem "quiet_assets", ">= 1.0.1", :group => :development
gem "figaro", ">= 0.5.3"
gem "better_errors", ">= 0.6.0", :group => :development
gem "binding_of_caller", ">= 0.6.9", :group => :development
gem 'client_side_validations'
gem 'fcm'
gem 'redis'
gem 'rack-cors'
gem 'certified'

group :production do
  gem 'thin'  
end

Upvotes: 0

Views: 268

Answers (1)

Udi Cohen
Udi Cohen

Reputation: 1289

Sorry, but mongoid 3.1 was released in 2013 and mongodb 3.4 was released 3 years later in 2016... It kinda make sense it will not work... Have you considered upgrading mongoid? or getting older mongodb?

If there's no way you can change the version you can try to only upgrade the mongo driver (bundle update mongo) and see what happens.

Upvotes: 1

Related Questions