Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2524

MongoUrlBuilder creates wrong url.

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            mail2stehle@gmail.com Sebastian Stehle
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: