Reputation: 1179
I created this simple application
using System;
using System.Configuration;
using System.Threading;
using Couchbase;
using Couchbase.Configuration;
namespace SimpleCouchClientTest
{
/// <summary>
/// Simple couch client test
/// </summary>
class Program
{
static void Main(string[] args)
{
var connectionString = "http://localhost:8091/pools/";
var bucketName = "testbucket";
var bucketPassword = "testbucket";
var numberOfLoops = 1000;
for (var i = 0; i <= numberOfLoops; i++)
{
var config = new CouchbaseClientConfiguration
{
Bucket = bucketName,
BucketPassword = bucketPassword,
};
config.Urls.Add(new Uri(connectionString));
Console.WriteLine("Creating client #" + i);
var couchClient = new CouchbaseClient(config);
Console.WriteLine("Client #" + i + " created.");
//Thread.Sleep(100); //-- uncomment this to run successfully
}
}
}
}
The numberOfLoops
is set to 1000, and the CouchbaseClient creation hangs after first client. I ran the WinDbg session and I learnt the client is getting stuck on BucketConfigListener.Start()
.
Is this a known issue? Are there any workarounds?
Upvotes: 1
Views: 517
Reputation: 541
I was having the same issue and finally got this figured out. I was running fiddler2 to inspect the contents of the web requests/responses. However, that was interfering with the bucketsStreaming URI.
Once I closed out fiddler2 and made sure no other proxies were in place, it worked just fine. I was able to also reproduce the issue on demand by restarting fiddler2 before trying to initialize the constructor.
Let me know if that was what you were experiencing as well.
Upvotes: 3
Reputation: 2848
Not sure what are you trying to test/achieve by creating multiple client instances? I don't think you should create so many Couchbase clients. Its supposed to be one client instance serving all your app threads.
You should move "new CouchbaseClient(config);" outside of the loop.
e.g.
var config = new CouchbaseClientConfiguration
{
Bucket = bucketName,
BucketPassword = bucketPassword,
};
config.Urls.Add(new Uri(connectionString));
Console.WriteLine("Creating one client for all my app needs");
var couchClient = new CouchbaseClient(config);
for (var i = 0; i <= numberOfLoops; i++)
{
// use client to do your test operations get/set/etc
}
Upvotes: 0