The exception "Invalid argument - connect(2)" of class Errno::EINVAL is being raised by the following code:
Mongoid.load!(Dir.pwd + '/config/mongoid.yaml')
Mongoid.configure do |config|
config.master = Mongo::Connection.new(Config.instance.global['CN'], 27017, pool_size: 50, pool_timeout: 15).db('test')
end
The code snippet above is in the file db_layer:81, from there the exception goes into the mongo driver.
The exception is thrown randomly by a connect_nonblock in the driver (lib/mongo/util/tcp_socket.rb:52).
Switching back to mongo 1.6.1 fixes the problem.
Backtrace:
"C:/RCS/Ruby/lib/ruby/gems/1.9.1/gems/mongo-1.6.2/lib/mongo/util/tcp_socket.rb:52:in `connect_nonblock'", "C:/RCS/Ruby/lib/ruby/gems/1.9.1/gems/mongo-1.6.2/lib/mongo/util/tcp_socket.rb:52:in `connect'", "C:/RCS/Ruby/lib/ruby/gems/1.9.1/gems/mongo-1.6.2/lib/mongo/util/tcp_socket.rb:22:in `initialize'",
"C:/RCS/Ruby/lib/ruby/gems/1.9.1/gems/mongo-1.6.2/lib/mongo/connection.rb:630:in `new'", "C:/RCS/Ruby/lib/ruby/gems/1.9.1/gems/mongo-1.6.2/lib/mongo/connection.rb:630:in `check_is_master'", "C:/RCS/Ruby/lib/ruby/gems/1.9.1/gems/mongo-1.6.2/lib/mongo/connection.rb:404:in `connect'", "C:/RCS/Ruby/lib/ruby/gems/1.9.1/gems/mongo-1.6.2/lib/mongo/connection.rb:594:in `setup'", "C:/RCS/Ruby/lib/ruby/gems/1.9.1/gems/mongo-1.6.2/lib/mongo/connection.rb:114:in `initialize'", "C:/RCS/DB/lib/test-db/db_layer.rb:81:in `new'",
"C:/RCS/DB/lib/test-db/db_layer.rb:81:in `block in connect'",
"C:/RCS/Ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.8/lib/mongoid.rb:116:in `configure'",
"C:/RCS/DB/lib/test-db/db_layer.rb:80:in `connect'",
"C:/RCS/DB/lib/test-db/manager.rb:34:in `run'",
"C:/RCS/DB/lib/test-db/manager.rb:122:in `run!'",
"bin/test:10:in `<main>'"