[CSHARP-2524] MongoUrlBuilder creates wrong url. Created: 15/Feb/19  Updated: 16/Nov/21  Resolved: 25/Feb/19

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Sebastian Stehle Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-2459 Do not output port in ToString() for ... Closed

 Description   

Hi,

I use the MongoUrlBuilder to extract the database name from a connection string, but the following code throws an exception

var mongoUrl = new MongoUrlBuilder("mongodb+srv://user:pass@host/Database?retryWrites=true") { DatabaseName = null };

ConnectionString = mongoUrl.ToMongoUrl();

MongoConfigurationException
Host for mongodb+srv scheme cannot specify a port.

When I use .ToString() I the following url back:

mongodb+srv://user:pass@host:53/?ssl=true;retryWrites=true

 

Which then throws the same exception when creating a MongoClient.



 Comments   
Comment by Sebastian Stehle [ 15/Feb/19 ]

Sorry, dupliacate of #CSHARP-2459 ... can be deleted.

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