GetBucket

Hello,
i tried running the example Couchbase.NetDP1 in C#.
I changed the code so i connect to my server and bucket:

private void button1_Click(object sender, EventArgs e)
{
Cluster cluster = InitializeCluster2();
var bucket = GetBucket(cluster, “NewUserLink”);
}

private Cluster InitializeCluster2()
{
//Create a custom configuration specifiy a max pool size of 10
ClientConfiguration configuration = new ClientConfiguration();
configuration.PoolConfiguration.MaxSize=10;
configuration.PoolConfiguration.MinSize=10;

        configuration.Servers.Clear();
        configuration.Servers.Add(new Uri("http://192.118.63.84:8091/pools"));

        BucketConfiguration bc = new BucketConfiguration();
        bc.Password = "mypass";
        bc.Username = "admin";
        bc.BucketName = "NewUserLink";

        bc.Servers.Clear();
        bc.Servers.Add("192.118.63.84");
        bc.Port = 11211;

        configuration.BucketConfigs.Clear();
        configuration.BucketConfigs.Add("NewUserLink", bc);

        //Initialize the cluster using the default configuration
        Cluster.Initialize(configuration);

        //Get an instance of the cluster;
        return Cluster.Get();
    }

private IBucket GetBucket(Cluster cluster, string bucketName)
{
//Open the default bucket

        return cluster.OpenBucket(bucketName);
    }

when i run it i get message: when i use the default port and bot set the bc.port i get message: “Invalid URI: Invalid port specified.” when i set the port to my bucket port 11211 i get the message: “Object reference not set to an instance of an object” in line “cluster.OpenBucket” .
any idea?
thanks,
ruby

Hi rubynadler -

There are a couple things going on here:

  • Looks like you found a bug! Internally, when the OpenBucket(bucketName) is called, it overrides the configured password with an empty string (which is the default password). This will be fixed in Beta 1, the ticket can be found here: https://www.couchbase.com/issues/browse/NCBC-514. As a work-around, you should be able to call OpenBucket(bucketName, password) and connect successfully.
  • I see your using port 11211, which is the proxy port for clients using Moxi. The .NET client doesn't use Moxi, so this isn't a valid configuration. The ticket for this is here: https://www.couchbase.com/issues/browse/NCBC-515
  • You may want to update your sample to DP2: http://blog.couchbase.com/couchbase-net-20-sdk-developer-preview-2. Note that Cluster is now CouchbaseCluster.

If you encounter any other bugs, feel free to open up an NCBC here: https://www.couchbase.com/issues/browse/NCBC and if you can, please include a “how-to-replicate” or project illustrating the issue.

Thanks!

-Jeff

when i try to change the bucket port on the server console to 11210 i get message that the port is already in use. the default port of the bucket is 11211 (and you say i can not connect with). so i changed the port to different port. in the c# code i changed the property of the port to the same port and get message:“No connection could be made because the target machine actively refused it”.