Unable to use LegacyTranscoder or any of the other Transcoders

I’m trying upgrade from Couchbase 4.0 to 6.5 and using SDK 3.0.1. We are only using kv and stores data as byte. I want to change as little code as possible keeping my old contract intact.

I found out that I have to use a Transcoder and/or serializer, but when I want to use it Couchbase throws a NullReferenceException.

private async Task InitializeClusterAsync()
{
    var options = new ClusterOptions()
    {
        KvTimeout = TimeSpan.FromSeconds(12),
        ManagementTimeout = TimeSpan.FromSeconds(12),
        EnableDnsSrvResolution = false,
    };
    options.WithConnectionString("couchbase://localhost")
           .WithCredentials(username: Username, password: Password)
           .WithSerializer(new DefaultSerializer())
           .WithTranscoder(new LegacyTranscoder());

    cluster = await Couchbase.Cluster.ConnectAsync(options);
}


   at Couchbase.Core.ClusterContext.<BootstrapGlobalAsync>d__49.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Couchbase.Cluster.<Couchbase-Core-Bootstrapping-IBootstrappable-BootStrapAsync>d__42.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Couchbase.Cluster.<ConnectAsync>d__22.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Brunata.Ulfberht.TestAssisters.CouchbaseBucketHelper.<InitializeClusterAsync>d__22.MoveNext() in C:\Source\Repos\Ulfberht.RIS\Ulfberht\Testing\TestAssisters\CouchbaseBucketHelper.cs:line 161

.NET SDK 3.0.1
Couchbase Server CE 6.5.1

Found out that you cannot use the LegacyTranscoder in the ClusterOptions, because it will use this transcoder when fetching configuration from cluster, which cannot be read with that transcoder.

In order to use the LegacyTranscoder it must be added to each call to the Collection.
Not sure if this is a bug or by design.

1 Like

Hi @msb -

Thanks for the post; indeed you will need to set the transcoder at the operation level as the ClusterOptions.Serializer property is actually for the internal configuration handler. I can’t say this is intended as only operation level transcoder overriding was planned; that being said it makes sense in some cases to allow this to be done globally. We don’t have anything planned short-term to todo this, that may change - if its a requested feature, please create a jira ticket and we will prioritize it accordingly.

-Jeff