Mongo 3.6 DNS Seedlist Connection Format

1,051 views
Skip to first unread message

Brent Wilkins

unread,
May 8, 2018, 1:12:14 PM5/8/18
to ReactiveMongo - http://reactivemongo.org
What are the plans, if any, to support the DNS seedlist connection format?

Thanks,

Brent

Cédric Chantepie

unread,
Jun 4, 2018, 2:41:48 PM6/4/18
to ReactiveMongo - http://reactivemongo.org
Could elaborate the feature request? So it could then be added to the github tracker?

Brent Wilkins

unread,
Jun 8, 2018, 4:59:50 PM6/8/18
to ReactiveMongo - http://reactivemongo.org


On Monday, June 4, 2018 at 12:41:48 PM UTC-6, Cédric Chantepie wrote:
Could elaborate the feature request? So it could then be added to the github tracker?


Here is the snippet from the mongo 3.6 documentation (https://docs.mongodb.com/manual/reference/connection-string/):
 

DNS Seedlist Connection Format

New in version 3.6.

In addition to the standard connection format, MongoDB supports a DNS-constructed seedlist. Using DNS to construct the available servers list allows more flexibility of deployment and the ability to change the servers in rotation without reconfiguring clients.

In order to leverage the DNS seedlist, use a connection string prefix of mongodb+srv: in place of the mongodb: string above.

The +srv indicates to the mongo client that the hostname that follows corresponds to a DNS SRV record. The client driver will then query the DNS for the record to determine the hosts that are running the mongod instances.

For example, to connect to a DNS-listed hostname:

A typical DNS configuration for the connection string above might look something like this:

Record                            TTL   Class    Priority Weight Port  Target
_mongodb._tcp.server.example.com. 86400 IN SRV   0        5      27317 mongodb1.example.com.
_mongodb._tcp.server.example.com. 86400 IN SRV   0        5      27017 mongodb2.example.com.

NOTE

The hostnames returned in SRV records must share the same parent domain (in this example, example.com) as the given hostname.

The DNS seedlist connection string can also provide options as a query string, with a trailing “/?” as in the standard connection string above. However, the +srv appended to the standard connection string signals the driver to query the DNS for options as a configured TXT record.

Only two options are available for configuration via a TXT record – replicaSet and authSource, and only one TXT record is allowed per server. If multiple TXT records appear in the DNS and/or if the TXT record contains an option other than replicaSet or authSource, an error will be thrown by the driver.

An example of a properly configured TXT record:

Record              TTL   Class    Text
server.example.com. 86400 IN TXT   "replicaSet=mySet&authSource=authDB"

In this case, taking into account both the DNS SRV records and the options retrieved from the TXT records, the parsed string will look like:

Options set in a TXT record can be overridden by passing in a query string with the URI. In the example below, the query string has provided an override for the authSource option configured in the TXT record of the DNS entry above.

The rest of the option string will remain, and we can expect that the resulting URI would look like this (after parse).

NOTE

The mongodb+srv option will fail if there is no available DNS with records that correspond to the hostname identified in the connection string. In addition, use of the +srv connection string modifier sets the ssl option to true automatically for the connection. This can be overridden by explicitly setting the ssl option to false with ssl=false in the query string.

Cédric Chantepie

unread,
Jun 26, 2018, 4:48:57 PM6/26/18
to ReactiveMongo - http://reactivemongo.org
Supported since 0.14

Asma'u Shaheedah

unread,
Jul 15, 2020, 6:09:28 AM7/15/20
to ReactiveMongo - http://reactivemongo.org
I have been trying to connect to an atlas cluster using the dns seed list connection string format but all i get is a: "MongoError['No primary node is available! (Supervisor-11/Connection-12)']"

On Tuesday, 26 June 2018 21:48:57 UTC+1, Cédric Chantepie wrote:
Supported since 0.14

Cédric Chantepie

unread,
Jul 15, 2020, 6:33:12 AM7/15/20
to ReactiveMongo - http://reactivemongo.org
Without more information, it's only possible to guess the configuration is wrong.

Asma'u Shaheedah

unread,
Jul 15, 2020, 7:11:11 AM7/15/20
to ReactiveMongo - http://reactivemongo.org
I followed the documentation to the letter from reactivemongo. my mongodb.uri in my application.conf is mongodb.uri = mongodb+srv://<username>:<password>@my-cluster.abo25.mongodb.net/my-db?retryWrites=true&w=majority All i received is "MongoError['No primary node is available! (Supervisor-13/Connection-14)']"

Asma'u Shaheedah

unread,
Jul 15, 2020, 9:02:08 AM7/15/20
to ReactiveMongo - http://reactivemongo.org
Also, i can access the db via mongo shell. Just not via my app

Cédric Chantepie

unread,
Jul 18, 2020, 5:24:57 PM7/18/20
to ReactiveMongo - http://reactivemongo.org

Carlos Saltos

unread,
Jul 19, 2020, 3:07:29 AM7/19/20
to reacti...@googlegroups.com
Sadly this is an old known bug for MongoDB 3.x ... at Talenteca we are using ReactiveMongo version 0.16.x until we are able to migrate to MongoDB 4.x

Best regards,

Carlos

Cédric Chantepie <chantep...@gmail.com> schrieb am Sa. 18. Juli 2020 um 23:24:
--
You received this message because you are subscribed to the Google Groups "ReactiveMongo - http://reactivemongo.org" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reactivemong...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/reactivemongo/83cd196f-684c-4b16-9c1f-fbb189c98ca7n%40googlegroups.com.

Cédric Chantepie

unread,
Jul 19, 2020, 7:21:40 AM7/19/20
to ReactiveMongo - http://reactivemongo.org
On Sunday, 19 July 2020 at 09:07:29:
Sadly this is an old known bug for MongoDB 3.x ... at Talenteca we are using ReactiveMongo version 0.16.x until we are able to migrate to MongoDB 4.x

I don't see your point.
ReactiveMongo 0.16.x can have issue now (as it's more than one year old), but later release are compatible with both MongoDB 3.x and MongoDB 4.x.
Reply all
Reply to author
Forward
0 new messages