Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-2219

Cluster instantiation using ClusterOptions ignores WithServers servers

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.0-beta.1
    • 3.0.0
    • library
    • None
    • .NET Core 3.0.1
    • 1

    Description

      Apologies if this turns out to be a matter of incorrect SDK usage. However, I have code like this:

       
      var connectionString = $"couchbase://{servers[0]}";
      var clusterOptionsServers = servers.Select(s => $"couchbase://{s}").ToArray();
      var options = new ClusterOptions()
           .WithServers(clusterOptionsServers)
           .WithCredentials(username, password)
           .WithBucket(_configBucketName);
      _cluster = new Cluster(connectionString, options);
       
      WithServers takes a "params string[]" and I am passing in an array of strings to the 4 cluster servers that we have. My expectation is that is one of them is down, it will open a connection on one of the others. However, whatever is passed into 'WithServers' seems to be ignored in favor of 'connectionString'. And if 'connectionString' is invalid or points to a server that is not running, there is no attempt to cycle through the server list provided in the ClusterOptions.WithServers.

      Attachments

        For Gerrit Dashboard: NCBC-2219
        # Subject Branch Project Status CR V

        Activity

          jmorris Jeff Morris added a comment - - edited

          Ryan Atkins -

          This is true, connectionString overwrites anything added by WithServers(...); note that connectionString is a required field and WithServers(..) is optional. WithServers is likely to be removed or made obsolete in the future.

          -Jeff

          jmorris Jeff Morris added a comment - - edited Ryan Atkins - This is true, connectionString overwrites anything added by WithServers(...); note that connectionString is a required field and WithServers(..) is optional. WithServers is likely to be removed or made obsolete in the future. -Jeff
          atkinsr Ryan Atkins added a comment -

          Thank you for the info Jeff. So, if WithServers is deprecated, is there going to be (or is there now) an alternate way to specify a list of available servers instead of only one? Or do we need to code that up ourselves (i.e., keep trying with different 'connectionString' values until we have successfully connect with one which is online)?

          atkinsr Ryan Atkins added a comment - Thank you for the info Jeff. So, if WithServers is deprecated, is there going to be (or is there now) an alternate way to specify a list of available servers instead of only one? Or do we need to code that up ourselves (i.e., keep trying with different 'connectionString' values until we have successfully connect with one which is online)?
          jmorris Jeff Morris added a comment -

          Ryan Atkins -

          The connectionString per the RFC can take a comma delimited list of servers: couchbase://10.0.0.1;10.0.0.2:11210;10.0.0.3

          -Jeff

          jmorris Jeff Morris added a comment - Ryan Atkins - The connectionString per the RFC can take a comma delimited list of servers: couchbase://10.0.0.1;10.0.0.2:11210;10.0.0.3 -Jeff
          atkinsr Ryan Atkins added a comment -

          Alright. Thank you for the suggestion. When I try that approach using syntax as follows:

          connectionString = "couchbase://host1.org.company.com;host2.org.company.com;host3.org.company.com"

          I get an exception when calling: new Cluster(connectionString, options)
          Or when calling: new Cluster(connectionString, username, password)

          An unhandled exception of type 'System.UriFormatException' occurred in Microsoft.AspNetCore.Hosting.dll: 'Invalid URI: The format of the URI could not be determined.'

          atkinsr Ryan Atkins added a comment - Alright. Thank you for the suggestion. When I try that approach using syntax as follows: connectionString = "couchbase://host1.org.company.com;host2.org.company.com;host3.org.company.com" I get an exception when calling: new Cluster(connectionString, options) Or when calling: new Cluster(connectionString, username, password) An unhandled exception of type 'System.UriFormatException' occurred in Microsoft.AspNetCore.Hosting.dll: 'Invalid URI: The format of the URI could not be determined.'
          jmorris Jeff Morris added a comment - - edited

          Ryan Atkins -

          Looks like a bug, this will fixed in the next release. Thanks for reporting!

          -Jeff

          jmorris Jeff Morris added a comment - - edited Ryan Atkins - Looks like a bug, this will fixed in the next release. Thanks for reporting! -Jeff

          People

            jmorris Jeff Morris
            atkinsr Ryan Atkins
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty