Cannot access Couchbase memcached buckets in Docker

I’m unable to access buckets created as memcached when Couchbase is hosted in Docker. See my docker-compose below. I can access the web client without problems.

Does anyone know if I need to map any other ports?

NOTE: I’m able to access all type of buckets if Couchbase Server is installed on Windows.

version: "3.7"
services:
  couchbase:
    container_name: couchbase
    image: couchbase:community-6.5.0
    volumes:
      - ./.docker/couchbase/var/:/opt/couchbase/var/
    networks:
      - back
    ports:
      - 4369:4369 
      - 8091-8096:8091-8096
      - 11207:11207
      - 11209-11211:11209-11211
      - 21100:21100 
      - 21200:21200 
      - 21300:21300
      - 9998:9998

Exception

Recieves two exceptions on cluster.OpenBucket(...) :

  • Could not bootstrap with CCCP.
  • Value does not fall within the expected range.

Is there no help to find in here? Couchbase team?

Hi @msb – Just in case this is a .net issue, I’m tagging @ingenthr and @jmorris - it probably is not, since it’s working fine directly on Windows, but just in case, would you post a short code sample?

Also (and I should have mentioned this on Stack Overflow), there is a tool called sdk-doctor, which can help identify if it’s a network issue.

This is an expected log event for memcached buckets as they do not support CCCP; the client then falls back to HTTP Streaming (port 8091) and then should bootstrap off of it.

This sounds like a side effect of something going wrong; is there more information (stacktrace, etc)?

-Jeff

Code

    public static ICluster CreateCluster(string host, string username, string password, int clientThreads = 1)
    {
        // Configuration of the access of buckets
        var bucketConfig = new BucketConfiguration
        {
            PoolConfiguration = new PoolConfiguration { MaxSize = clientThreads, MinSize = clientThreads, SendTimeout = 12000 }
        };

        // Cluster client configuration
        var clientConfig = new ClientConfiguration
        {
            Servers = new List<Uri>() { new Uri($"http://{host}:8091/pools") },
            UseSsl = false,
            // "default" referes to default configuration and not default bucket
            BucketConfigs = new Dictionary<string, BucketConfiguration> { { "default", bucketConfig } },
        };

        var cluster = new Cluster(clientConfig);
        var authenticator = new PasswordAuthenticator(username, password);
        cluster.Authenticate(authenticator);
        
        return cluster;
    }

Here is the stacktrace for the different exceptions:

Could not bootstrap - check inner exceptions for details.

   at Couchbase.Core.ClusterController.CreateBucketImpl(String bucketName, String password, IAuthenticator authenticator)
   at Couchbase.Core.ClusterController.CreateBucket(String bucketName, String password, IAuthenticator authenticator)
   at Couchbase.Cluster.OpenBucket(String bucketName, String password)
   at Couchbase.Cluster.OpenBucket(String bucketname)
   at Brunata.Ulfberht.Cache.CouchbaseCache`1..ctor(ISerializer`1 serializer, CouchbaseCacheConfiguration config) in C:\Source\Repos\Ulfberht.RIS.Core\Ulfberht\CMN.Cache\CouchbaseCache.cs:line 68

Inner exceptions:

Could not bootstrap with CCCP.

   at Couchbase.Configuration.Server.Providers.CarrierPublication.CarrierPublicationProvider.GetConfig(String bucketName, String username, String password)
   at Couchbase.Core.ClusterController.CreateBucketImpl(String bucketName, String password, IAuthenticator authenticator)

Value does not fall within the expected range.

   at Couchbase.Configuration.Server.Providers.Streaming.HttpStreamingProvider.GetConfig(String bucketName, String username, String password)
   at Couchbase.Core.ClusterController.CreateBucketImpl(String bucketName, String password, IAuthenticator authenticator)

Try removing the “/pools” portion of the bootstrap uri above.

Same error.

We’re using the REST API to create the buckets without any problems.

    public async Task CreateBucketAsync()
    {
        var content = new FormUrlEncodedContent(new[]
        {
                new KeyValuePair<string, string>("name", bucketName),
                new KeyValuePair<string, string>("ramQuotaMB", "100"),
                new KeyValuePair<string, string>("bucketType", "memcached"),
                new KeyValuePair<string, string>("flushEnabled", "1")
            });

        var response = await client.PostAsync($@"pools/default/buckets", content);

        if (response.StatusCode != HttpStatusCode.Accepted)
            throw new InvalidOperationException($"Unable to create bucket {bucketName}");
    }

Could it be something missing in the container image?

The reason we are using memcached buckets is only for testing and because memcached buckets are much faster to flush then regular buckets. .

This also works if I use ephemeral buckets, but…

We have 55 tests that run against Couchbase, which takes 1.7 sec to run if buckets are memcached, but over 3 min if the buckets are of type ephemeral.

We also a have about 200 function tests that today takes 45 min to run with memcached buckets. Before each scenario each buckets (count: 6) is flushed. Using couchbase buckets would add 30 sec to each test which would mean that the total test run would be 145 min.

I suspect that there maybe an intermittent bug when sdk2 is used with Couchbase Server 6.5 or greater that affects the bootstrapping process; the REST API doesn’t go through this process which is why it works .

I created a ticket for tracking, would it be possible to post a log file of the bootstrapping process?

-Jeff

@jmorris which log files do you mean? How do I collect the logs?

Add the following NuGet package as a dependency to your project:

<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />

In Program.cs class configure logging on web host builder:

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureLogging((hostingContext, builder) =>
        {
            builder.AddFile("Logs/myapp-{Date}.txt", LogLevel.Debug);
        })
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup<Startup>();
        });

-Jeff

Be aware that I’m running 2.7.x and on .NET 4.8, but I manage to add Log4Net to gather the log.

I have create two logs: One against a Memcached bucket and one against a Couchbase bucket.

logs.zip (9.8 KB)