Open AdrienDS opened 6 years ago
It happens only with shared clusters: we tried on an m2 cluster (shared as well) and had the same issue. https://docs.atlas.mongodb.com/reference/free-shared-limitations/
However after upgrading to a dedicated cluster (M10) the connection works fine.
I still think it would be great to have a fix for this to be able to connect to Mongo Atlas shared clusters.
Unfortunately I have no setup at hand on which I would be able to try, but I believe that you can specify server name like this:
from twisted.internet import ssl
ConnectionPool(url, ssl_context_factory=ssl.optionsForClientTLS('your.atlas.server.name'))
@IlyaSkriblovsky Thanks, that solved the issue ! (ssl.optionsForClientTLS('your-atlas-server-name.mongodb.net')
I still think it might be good to handle this error to show more information to the user:
txmongo/connection.py l105
reads config.get("err", "Unknown error")
err
but an errmsg
, code
and codeName
Specifying the hostname via ssl.optionsForClientTLS
manually does the trick. In my case, the cluster name is cluster0.foobar.mongodb.net
, which resolves to cluster0-shard-00-00.foobar.mongodb.net
, cluster0-shard-00-01.foobar.mongodb.net
, and so on. I just pick one of them.
But I suppose it does not work all the time.
For a shared cluster (SNI required) with multiple nodes like Atlas, the hostnames of those nodes are given in the SRV record as well as updated from the ismaster
query result. These hostnames are different and, technically, dynamic. I guess the reason why picking any one of them as the SNI does the trick is that Atlas accepts any identifiable subdomain on any nodes in the TLS layer for convenience (like Domain fronting), which should not be relied upon.
So I think it is still meaningful to let txmongo handles SNI itself instead.
I am trying to connect to an Atlas M0 (Free Tier) Cluster with txmongo.
Following the instructions here: https://github.com/twisted/txmongo/issues/203 I created the connection pool with:
db = yield ConnectionPool(url, ssl_context_factory=ssl.ClientContextFactory())
But I get the following error in the logs when trying to start my app:
Here is more info about actual error (as seen in
txmongo/connection.py l105
):config = {'ok': 0, 'errmsg': 'no SNI name sent, make sure using a MongoDB 3.4+ driver/shell.', 'code': 8000, 'codeName': 'AtlasError'}
Do you know how I can solve this ?
Thank you for your time.