Fail to authenticate user on db with ruby driver 1.9.2

When I login mongodb in my ruby code against ruby driver 1.9.2, always told me the

Failed to authenticate user ‘appuser’ on db ‘details_info’

db_options = {
 
    ssl: false,
 
    pool_size: 40,
 
    pool_timeout: 30
 
}

client = MongoClient.from_uri("mongodb://appuser:appuserpassword@10.38.99.11/details_info")
col = client.db('details_info').collection('test_report')
col.insert(...)

logs:

Mongo::AuthenticationError: Failed to authenticate user 'appuser' on db 'details_info'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/db.rb:179:in `issue_authentication'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/mongo_client.rb:275:in `block in apply_saved_authentication'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/mongo_client.rb:274:in `each'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/mongo_client.rb:274:in `apply_saved_authentication'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/util/pool.rb:190:in `checkout_new_socket'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/util/pool.rb:288:in `block (2 levels) in checkout'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/util/pool.rb:279:in `synchronize'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/util/pool.rb:279:in `block in checkout'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/util/pool.rb:272:in `loop'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/util/pool.rb:272:in `checkout'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/mongo_client.rb:563:in `checkout_writer'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/networking.rb:85:in `send_message_with_gle'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/collection.rb:1121:in `block in send_insert_message'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/util/logging.rb:55:in `block in instrument'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/util/logging.rb:20:in `instrument'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/util/logging.rb:54:in `instrument'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/collection.rb:1119:in `send_insert_message'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/collection.rb:1111:in `insert_batch'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/collection.rb:1169:in `insert_documents'D:/Workspace/ruby230/2.3.0/lib/ruby/gems/2.3.0/gems/mongo-1.9.2/lib/mongo/collection.rb:389:in `insert'

When I use ruby driver 2.14.0, the authentication is successfully, but doesn’t work in 1.9.2. could you please give me some help?

1 Like

Hi @tracy_ren,

The MongoDB Ruby 1.9.2 driver was released in August, 2013 and predates support for modern MongoDB server features and authentication methods. The latest production release of MongoDB when this driver version was released was MongoDB 2.4.

If you are connecting to a newer MongoDB server, you will also have to update your driver version. See Ruby Driver Compatibility for a reference of supported driver and server combinations.

Regards,
Stennie