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

1 Answer

« Back to question.

Hi rubynadler -

There are a couple things going on here:

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".