PyMongo MongoDB Cloud Atlas and Python 2.7.2 can't connect

309 views
Skip to first unread message

Benoît HERVIER

unread,
Mar 29, 2017, 4:18:52 PM3/29/17
to mongodb-user
Hi,

I'm currently trying to connect to a mongodb cloud Atlas instance, while the code is working fine on desktop with py2.7.12. I can't auth with Python 2.7.2 on iOS or Android, I got a ServerSelectionTimeoutError.

1/ how can I get details of this error to understand what happen really in background ?

2/ Does pymongo3.4 support Python 2.7.2 ?

Thanks

Bernie Hackett

unread,
Mar 30, 2017, 11:12:42 AM3/30/17
to mongodb-user
Python versions before 2.7.9 have various problems with TLS/SSL that have to be solved through third party packages. Assuming you are using PyMongo 3.3 or later, you can install any necessary dependencies like this:

python -m pip install pymongo[tls]


If you're curious what the extra packages are, or you're using an older 3.x version of PyMongo and have to install the extra packages manually:

Benoît HERVIER

unread,
Mar 31, 2017, 4:30:00 AM3/31/17
to mongodb-user
Thanks Bernie,

I m alreading importing certifi, i can now reproduce the error using python 2.7.2 also on desktop.

I use the following snippet

uri = "mongodb://user:pa...@cluster0-shard-00-00-ycpfg.mongodb.net:27017,cluster0-shard-00-01-ycpfg.mongodb.net:27017,cluster0-shard-00-02-ycpfg.mongodb.net:27017/datas?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&ssl_ca_certs="+certifi.where()

db_storage = pymongo.MongoClient(uri)
db_storage.admin.command('ismaster')

I m probably doing something wrong, but i dont understand what.

Thanks

Benoît HERVIER

unread,
Mar 31, 2017, 4:56:19 AM3/31/17
to mongodb-user
I use the following example :

http://api.mongodb.com/python/2.9.4/atlas.html

But something look like missing for 2.7.2.

Thanks


Le vendredi 31 mars 2017 10:30:00 UTC+2, Benoît HERVIER a écrit :
Thanks Bernie,

I m alreading importing certifi, i can now reproduce the error using python 2.7.2 also on desktop.

I use the following snippet

Bernie Hackett

unread,
Mar 31, 2017, 9:53:22 AM3/31/17
to mongodb-user
You might be hitting this python bug, which was reported in Python 2.7.2:


There is no changelog entry for the fix, so it's not clear what version of 2.7 the fix was released in, but it was clearly 2.7.3 or later.

If you post the traceback you're getting, I can confirm.

Reply all
Reply to author
Forward
0 new messages