Unable to connect to Memcached bucket from C#

Hello,
I am trying to connect to a memcached from C# and getting the exception:

is this a Memcached bucket?
2017-01-25 08:46:48,097 ERROR Control:LoadRecursive Error while processing pageWPUtils.WPException: FrontEndCacheManager:GetFrontEndCachedItem front end cache bucket name: cache, url: cacheSystem.AggregateException: Could not bootstrap - check inner exceptions for details.[ at Couchbase.Core.ClusterController.CreateBucket(String bucketName, String password)
at Couchbase.Core.ClusterController.CreateBucket(String bucketName)
at WPUtils.FrontEndCacheManager.InitializeBuckets()] , InnerException: Couchbase.Configuration.ConfigException: is this a Memcached bucket?[ at WPUtils.FrontEndCacheManager.InitializeBuckets()
at WPUtils.FrontEndCacheManager.GetFrontEndCachedItem(String url, TimeSpan expiration)
at webmobile.home.ProcessSitePage(BLMediaSite mediaSite, BLPage oPage, MSGXWWWSContext msgcontext, Dictionary`2 addParams, Guid oCurrSiteVisitGuid, FrontEndCacheTaskHandler taskHandler)
at webmobile.home.Page_Load(Object sender, EventArgs e)]

I am running on Couchbase server 4.0.0 and client SDK 2.2.5
I checked the connection from code I wrote in node.js and was successful.
I added a non default port, just to check if that works around the problem - it didn’t
I added a password, just to check if that works around the problem (like I read in another post Unable to connect to memcached bucket with .NET SDK 2.0.2) - it didn’t

Need your help - My only workaround for now, is to work with Couchbase bucket and not Memcached bucket.

Regards,
Alon

Hi @alonspiegel -

Can you provide the code and configuration you are using to connect to the Memcached bucket?

-Jeff

//
// Define the couchbase cluster
//
private static Cluster _cluster = new Cluster(new ClientConfiguration
{
	MaxViewRetries = 5,
	Servers = new List<Uri> {new Uri(WPConf.Instance.CouchbaseCacheClusterUrl)},
	BucketConfigs = new Dictionary<string, BucketConfiguration> 
		{
			{
				WPConf.Instance.FrontEndCacheBucketName, /* bucket name is provided from config */
				new BucketConfiguration
				{
					PoolConfiguration =
						new PoolConfiguration
						{
							MaxSize = 30,
							MinSize = 5
						}
				}
			}
		}
});
 
 
 
//
// Open the bucket
// ===> here we get the exceptions
//
_frontEndCacheBucket = _cluster.OpenBucket(WPConf.Instance.FrontEndCacheBucketName);

@alonspiegel -

The config looks ok to me; but I need you to enable client logging (use Common.Logging.Log4Net1213 v3.3.1) to find out what is causing the AggregateException to be thrown. You can send them to me via a direct message if you don’t want to post them.

One thing you may want to try, for sanities sake, creating another Memcached bucket using all default settings and seeing if you can connect to it.

-Jeff

Hi,
Sorry it took me some time, I had to write a new program from scratch because the original didn’t produce any logs fror some reason.

I’m attaching a file with:

  • log.txt - The log you asked for
  • output.txt - The output with the exception
  • Program.cs - The program file of the small program I used to check
  • CouchbaseTester.rar - The solution and project with the program
    Archive.zip (14.0 KB)

@alonspiegel -

That link returns a 404. Can you create a ticket at https://issues.couchbase.com/projects/NCBC/summary and attach the file there?

Thanks,

Jeff

Sorry,
I don’t have an account

Regards,
Alon

@alonspiegel -

You should be able to create an account.

-Jeff

@alonspiegel -

Looking at the logs, here is the cause of the issue:

Bootstrapping failed from **http://172.xx.xxxx.7/pools**: System.Net.Http.HttpRequestException: An error occurred while sending the request. —> System.Net.Http.HttpRequestException: An error occurred while sending the request. —> System.Net.WebException: Unable to connect to the remote server —> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 172.xxx.xxx.7:80

The issue seems to be that your bootstrap url lacks the proper port number, so the SDK defaults to port 80 which fails because its the wrong bootstrap port. Try changing your bootstrap port to:

http://172.xx.xxxx.7:8091/pools

I didn’t check, but I suspect a Couchbase bucket works because the SDK always starts bootstrapping over TCP using port using the default 11210 if none is provided.

-Jeff

Hi Jeff,
You were correct.
Problem solved
Once I set the connection to url to couchbase://hostname:8091 I was able to connect.
I wonder why the .NET Couchbase driver is not using 8091 as the default port like other drivers (such as node.js)…

Regards,
Alon

@alonspiegel -

I created a ticket to make the behavior more consistent with node: https://issues.couchbase.com/browse/NCBC-1305

Thanks,

Jeff