I’m using C# drivers on Unity.
This is the connection format that I’ve been using:
mongodb+srv://<user>:<password>@<host_url>
It works great in the editor. However, when building to android, I get an ArgumentOutOfRangeException and the MongoClient initialization fails:
03-11 12:08:05.918 28988 29017 E Unity : ArgumentOutOfRangeException: List of configured name servers must not be empty.
03-11 12:08:05.918 28988 29017 E Unity : Parameter name: servers
03-11 12:08:05.918 28988 29017 E Unity : at DnsClient.LookupClient.QueryInternal (DnsClient.DnsQuestion question, DnsClient.DnsQuerySettings queryOptions, System.Collections.Generic.IReadOnlyCollection`1[T] servers) [0x00000] in <00000000000000000000000000000000>:0
03-11 12:08:05.918 28988 29017 E Unity : at MongoDB.Driver.Core.Misc.DnsClientWrapper.ResolveTxtRecords (System.String domainName, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0
03-11 12:08:05.918 28988 29017 E Unity : at MongoDB.Driver.Core.Configuration.ConnectionString.Resolve (System.Boolean resolveHosts, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0
03-11 12:08:05.918 28988 29017 E Unity : at MongoDB.Driver.MongoUrl.Resolve (System.Boolean resolveHosts, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0
03-11 12:08:05.918 28988 29017 E Unity : at MongoDB.Driver.MongoClientSettings.FromUrl (MongoDB.Driver.MongoUrl url) [0x00000] in <0000000000000000000000000000000
I’ve tried removing the “+srv” part of the connection string like this:
mongodb://<user>:<password>@<host_url>
… but when doing this, the MongoClient initialization is successful but when communicating with the database afterwards, I get an System.TimeoutException. This happens both inside the Editor and device builds:
03-11 12:14:06.783 30434 30457 I Unity : System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/production.vjcfb.mongodb.net:27017" }", EndPoint: "Unspecified/production.vjcfb.mongodb.net:27017", ReasonChanged: "Heartbeat", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.Net.Sockets.SocketException: Could not resolve host 'production.vjcfb.mongodb.net'
03-11 12:14:06.783 30434 30457 I Unity : at System.Net.Dns.Error_11001 (System.String hostName) [0x00015] in <1e1a09bd7c4e407788af79f6b1d8f250>:0
03-11 12:14:06.783 30434 30457 I Unity : at System.Net.Dns.G
Any idea what’s going on here? Thanks in advance!