N1QL query not working, Opening Bucket is too slow on server

I have built an application using Couchbase with .NET SDK. It is a simple add/ edit/ delete/ list application. All of the operations work fine when I use Couchbase installed on local machine.
Then I installed couchbase-server-enterprise_4.6.3 on Azure Virtual Machine following steps from here:

When I try to access couchbase on this virtual machine using my .net SDK, it takes a very long time to get a bucket. And it does not allow me to query the bucket using N1QL. Below is the code that I am using:

public static ClientConfiguration GetClientConfiguration()
return new ClientConfiguration
Servers = new List
new Uri(“http://MyVMName.cloudapp.net:8091/pools”),
UseSsl = false,
BucketConfigs = new Dictionary<string, BucketConfiguration>
new BucketConfiguration
BucketName = “MyBucket”,
UseSsl = false,
Password = “MyBucketPassword”,
PoolConfiguration = new PoolConfiguration
MaxSize = 10,
MinSize = 5
public static DataTable GetRecordsFromCouchBase(int int_Selected_Record_Count)
var bucket = ClusterHelper.GetBucket(“MyBucketName”); //Takes a very long time here
var query = bucket.Query("SELECT MyBucketName.* FROM MyBucketName ");
//Running this N1QL gives below error, I have also tried fetching only one record. But that doesn’t work most of the time, a very few times fetching a single record has worked


Error I get while executing N1QL:
Exception Message: An error occurred while sending the request.
Inner Exception: Unable to connect to the remote server
Stack Trace: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Couchbase.N1QL.QueryClient.<ExecuteQueryAsync>d__191.MoveNext()
Source: mscorlib

I have also tried giving the Client Configuration in web.config. But that too has not helped.

Hi @ishasood14

I think this may be a networking issue where additional ports need to be opened between your application and the VMs running Couchbase Server. Please see here for what ports Couchbase uses.

The slow opening of a bucket could be because the CCCP port 11210 is not available so the SDK falls back to using HTTP streaming, which is slower.

Not being able to execute N1QL queries is likely because port 8093 is not open, so it’s unable to send the request to the cluster.

Hope this helps.

1 Like