NCBC-824 regression? (Authentication exception when opening memcached bucket with password from ClientConfiguration)

Hello,
I am currently using CouchbaseNetClient 2.2.7, connecting to a test cluster running CB community 3.0.1. Memcached bucket type.

When connecting to a memcached bucket using configurations in app config, I get an access denied error. Overriding the app config by adding bucket name and password to the OpenBucket() call allows me to connect without any problem.
This seems rather similar to what described in NCBC-824, supposedly fixed in client 2.0.2.

To reproduce:

[edit - config copied from sample on SDK documentation, relevant line is this}:

  <buckets>
    <add name="test" useSsl="false" password="test">
         <connectionPool name="custom" maxSize="10" minSize="5"></connectionPool>
    </add>
  </buckets>
</couchbase>

Call:
using (var ppcluster = new Cluster(“couchbaseClients/couchbase”))
{
IBucket ppBucket = null;
try
{
using (ppBucket = ppcluster.OpenBucket())
{}
}
this throws this:
Exception thrown: ‘System.Security.Authentication.AuthenticationException’ in Couchbase.NetClient.dll
Exception thrown: ‘System.AggregateException’ in Couchbase.NetClient.dll
Exception thrown: ‘System.Net.WebException’ in System.dll
Exception thrown: ‘System.Security.Authentication.AuthenticationException’ in Couchbase.NetClient.dll
Exception thrown: ‘System.AggregateException’ in Couchbase.NetClient.dll

If I change the call to be
using (ppBucket = ppcluster.OpenBucket(“test”,“test”))
it works fine (same app.config).

Any chance anybody can have a look?

Thanks.

@paolop

I think your problem is the bucket name. Calling OpenBucket without any bucket name will always try to open a bucket named “default”, but your bucket appears to be named “test”. Try calling OpenBucket(“test”), that should automatically use the password from your configuration file.

Brant

Thanks for replying.

My code is copied verbatim from the documentation for the .net sdk when using an app.config file (under “configuring the client”, see below). If the behavior is ‘by design’, then the docs are incorrect.

using (var cluster = new Cluster("couchbaseClients/couchbase")) { using (var bucket = cluster.OpenBucket()) { //use the bucket here } }

IMHO, having to define the bucket name in code defeats the purpose of having this configurable in the app.config file. Sometimes you might want to release a package that can be deployed by only changing the config files, and not recompiling.
The workaround is trivial (just add bucket name and PW as variables somewhere else in the app.config file and then use these as parameters when opening the bucket}, but it is somewhat inelegant.

Thanks again,
Paolo

@paolop -

You make a good point; the reason OpenBucket() doesn’t just open the configured bucket is because you could have multiple buckets defined and which one would we chose?

We are open to improving this, however, so feedback is always appreciated.

-Jeff

@paolop

Just to be clear, you don’t need to put the password elsewhere in your config. It will use the password the way you have it configured. You just need to include the bucket name in the OpenBucket call, like .OpenBucket(“test”)

Brant

1 Like

Ok, thanks for the explanation.