Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error authenticating with mongo 3.0 #17

Open
rchamorro opened this issue Nov 29, 2017 · 2 comments
Open

Error authenticating with mongo 3.0 #17

rchamorro opened this issue Nov 29, 2017 · 2 comments

Comments

@rchamorro
Copy link

rchamorro commented Nov 29, 2017

When using mongodb_backend with authentication we have this error when updating a module (giscedata_telegestion_comer):

Traceback (most recent call last):
File "./openerp-server.py", line 112, in <module>
tools.config['update'])
File "/home/erp/src/erp/server/bin/pooler.py", line 42, in get_db_and_pool
addons.load_modules(db, force_demo, status, update_module)
File "/home/erp/src/erp/server/bin/addons/init.py", line 786, in load_modules
r = load_module_graph(cr, graph, status, report=report)
File "/home/erp/src/erp/server/bin/addons/init.py", line 630, in load_module_graph
init_module_objects(cr, package.name, modules)
File "/home/erp/src/erp/server/bin/addons/init.py", line 374, in init_module_objects
result = obj._auto_init(cr, {'module': module_name})
File "/home/erp/src/erp/server/bin/addons/mongodb_backend/orm_mongodb.py", line 52, in _auto_init
db = mdbpool.get_db()
File "/home/erp/src/erp/server/bin/addons/mongodb_backend/mongodb2.py", line 225, in get_db
raise except_orm('MongoDB connection error', e)
osv.orm.except_orm: error -- MongoDB connection error
error -- MongoDB connection error

We were able to solve it changing the uri property of mongodb2.py to not include the database name. Like this:

Line 137:

uri_tmpl = 'mongodb://%s:%s@%s:%s/?authMechanism=%s'
uri = uri_tmpl % (tools.config['mongodb_user'],
                                  tools.config['mongodb_pass'],
                                  tools.config['mongodb_host'],
                                  tools.config['mongodb_port'],                                  
                                  tools.config['mongodb_auth'])

But it then it fails authenticating with normal usage of the module :(

@jaumef
Copy link

jaumef commented Nov 29, 2017

@rchamorro The URI build should resemble to Official Mongodb Uri documentation:
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]

I think this is related to the "?options" concatenation to the URI.
The "database" section is mandatory on some methods for the MongoDB Pool Class.

@ecarreras
Copy link
Member

I think this should be fixed as we work with Mongo 3.0.12 @jaumef can you confirm it works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants