Is there a way to connect in a synchronous way to Couchbase Capella?

Hi!

I have a method that is overriding another one, the problem is that these methods return void, they are not asynchronous operations. Is there a way to make the connection to my Couchbase Capella cluster in a synchronous way?

All of this is done in a 4.7.2 NET application with 3.14.11 couchbase SDK

This is the code of my method (Using ASYNC, I know that im not modifying the methods to be async Task. I already did that and did not work, it is just an example for you to see what i need to do):

public override void MapProperties() {
string endpoint = “connectionString”;
string username = “DBUserName”;
string password = “DBPassword”;
string bucketName = “BucketName”;
string scopeName = “ScopeName”;
string collectionName = “CollectionName”;
string key = “Document ID”;

        var options = new ClusterOptions()
          .WithConnectionString(endpoint)
          .WithCredentials(username, password);

        var cluster = await Couchbase.Cluster.ConnectAsync(options);
        var bucket = await cluster.BucketAsync(bucketName);
        var scope = bucket.Scope(scopeName);
        var collection = scope.Collection(collectionName);

        var getResult = await collection.GetAsync(key);
        var resultContent = getResult.ContentAs<JObject>();
}

This is overriding a method in a parent class declared as:

public asbtract void MapProperties();

My question is, is there a way to do the same but in a synchronic way?

Just to clarify, the credentials are okay, the issue is not related to that

i tried to modify every method from void to async Task but didnt worked I also tried to use WaitUntilReady but it keeps saying that the Cluster is not bootstraped yet.

Maybe the problem is not related to asynchronous operations, but what could be?
This is the specific issue:
mscorlib, Version=4.0.0.0, Culture=neutral, Cluster has not yet bootstrapped. Call WaitUntilReadyAsync(…) to wait for it to complete.mscorlib en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
en System.Threading.Tasks.ValueTask`1.get_Result()

Usually that has to work before anything else will work. Pay close attention for the reasons that is failing and sort that out.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.