orlandos-nl / MongoKitten

Native MongoDB driver for Swift, written in Swift

Home Page:https://orlandos.nl/docs/mongokitten/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support DNS Seedlist Connection Format

Dev1an opened this issue · comments

Looking at the following lines, it seems that the DNS Seedlist connection format isn't supported yet.
https://github.com/OpenKitten/MongoKitten/blob/10f7befcdfac18cad8a752d6a6dd950512eb0151/Sources/MongoKitten/ConnectionSettings.swift#L126-L128

Are there any plans to support this feature? It is documented at: https://docs.mongodb.com/manual/reference/connection-string/#dns-seedlist-connection-format

I made a free cluster using https://cloud.mongodb.com and it gives me the following connection uri: mongodb+srv://<USERNAME>:<PASSWORD>@cluster0-5nnms.gcp.mongodb.net/test?retryWrites=true

So I guessed the host name would be: cluster0-5nnms.gcp.mongodb.net. But if I do an nslookup cluster0-5nnms.gcp.mongodb.net using the terminal I get:

Non-authoritative answer:
*** Can't find cluster0-5nnms.gcp.mongodb.net: No answer

So I have no idea how to get it to work...

OK, I dug a bit further and wile looking at the nodeJS implementation of the connection URI parser, I found out that one has to prefix the host in the mongo+srv uri with _mongodb._tcp.

So if you want to find out the hosts of your cluster, the nslookup command should look like:

nslookup -querytype=srv _mongodb._tcp.<host from mongo+srv uri>

and this should give you back a list of

<request>	service = <priority> <weight> <port> <host>

Hello @Dev1an, as it happens I've been discussing this implementation with one of the MongoDB leads. The problem isn't necessarily the SRV implementation but the failover to the other cluster nodes using SDAM.

Yes indeed that is the other part of connecting to a cluster... What is the problem with SDAM?

The problem is testing if it's working after implementing it. The previous time we implemented switching within a cluster the code was a mess (mind you, this was before MongoDB started their spec repo) and we weren't able to verify if it's working in real life scenarios. The limited test scenario we had showed it worked, but as @valeriomazzeo can confirm, this was far from always the case.

This is almost ready in MongoKitten 5.

We're stuck on the implementation because we're unable to call res_init here because of a linker error. If anyone knows how to solve this, your help is very welcome!