[CSHARP-2697] mongodb+srv connection string no longer works with version 2.9.0 Created: 19/Aug/19  Updated: 28/Oct/23  Resolved: 20/Aug/19

Status: Closed
Project: C# Driver
Component/s: Connectivity
Affects Version/s: 2.9.0
Fix Version/s: 2.9.1

Type: Bug Priority: Blocker - P1
Reporter: José Mira Assignee: Dmitry Lukyanov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by CSHARP-2698 Cannot connect using SRV in 2.9.0 C# ... Closed
is duplicated by CSHARP-3429 just declaring a `new MongoClient(con... Closed

 Description   

Using a connection string with the format

mongodb+srv://<username>:<password>@fireflydev-horrk.gcp.mongodb.net?retryWrites=true

I can successfully connect to sharded cluster using the C# client version 2.8.1

Unfortunatelly, when attempting to connect to the same cluster with the C# client version 2.9.0, using the same connection string and the same code, I get a timeout exception, hence not being able to connect:

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 : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [] }.

This is the stack trace on this exception:

at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description) in Cluster.cs:line 366
 at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask) in Cluster.cs:line 549
 at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken) in Cluster.cs:line 346
 at MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken) in Cluster.cs:line 234
 at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken) in MongoClient.cs:line 421
 at MongoDB.Driver.MongoClient.AreSessionsSupported(CancellationToken cancellationToken) in MongoClient.cs:line 395
 at MongoDB.Driver.MongoClient.UsingImplicitSession(Action`1 func, CancellationToken cancellationToken) in MongoClient.cs:line 557
 at MongoDB.Driver.MongoClient.DropDatabase(String name, CancellationToken cancellationToken) in MongoClient.cs:line 125
 at ConnectionString2_9.Program.Main() in C:\Users\jose.mira\source\repos\DevConnectionTests\ConnectionString2_9\Program.cs:line 21

I am missing something on the connection string?
 



 Comments   
Comment by Jeffrey Yemin [ 20/Aug/19 ]

Author:

{'username': 'DmitryLukyanov', 'email': 'dmitry.lukyanov@mongodb.com', 'name': 'Dmitry Lukyanov'}

Message: CSHARP-2642: Add srv connection strings to atlas connectivity tests. Fix the issue with initial host resolving for replica set.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/c50d9f9a63c81805ab33fd4909d43d7d1d9895e5

Comment by José Mira [ 19/Aug/19 ]

Forgot to mention that this is happening when connecting to a cluster running MongoDb Atlas version 4.0.12

Generated at Wed Feb 07 21:43:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.