simagix/keyhole

keyhole can't connect to atlas cluster

Closed this issue · 3 comments

It appears that "keyhole" has trouble connecting to an Atlas cluster

Given a MDB URI:

atlas_uri=$(echo mongodb+srv://${UN}:${PW}@sghtest2-pri.qurxw.mongodb.net/test)

where UN and PW are set to the username and password respectively

keyhole fails to connect

$ ./keyhole -simonly $atlas_uri
2021/02/04 22:11:08 error parsing uri: lookup <server-redacted> on 127.0.0.53:53: cannot unmarshal DNS message

Yet the mongo shell connects just fine

$ mongo --quiet $atlas_uri --eval 'db.version()' | grep -v NETWORK
4.0.22

The keyhole version is

$ ./keyhole -version
simagix/keyhole v1.0.4-20210126

Verified and it worked.

keyhole -info "mongodb+srv://${user}:${password}@cluster0.jgtm2.mongodb.net/test"
MongoDB v4.2.12 enterprise atlas-uzozci-shard-00-01.jgtm2.mongodb.net (CentOS Linux release 7.9.2009 (Core)) mongod replica 2 cores 1799 mem

If you use special characters in your password, use HTML encode or leave the password out and it'll prompt you for a password, for example 

keyhole -simonly "mongodb+srv://${user}@cluster0.jgtm2.mongodb.net/test"

There are no special characters in the password.

This test was done in GCP using peering. Did you test in that scenario?

The error that keyhole produces is:
$ ./keyhole --info $atlas_uri
2021/02/05 14:49:01 error parsing uri: lookup on 127.0.0.53:53: cannot unmarshal DNS message

There appears to be something wrong with how keyhole resolves DNS, at least in GCP using a peering connection between client and cluster.