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:
https://developer.couchbase.com/documentation/server/current/install/deployment-azure.html
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>
{
{
“MyBucket”,
new BucketConfiguration
{
BucketName = “MyBucket”,
UseSsl = false,
Password = “MyBucketPassword”,
PoolConfiguration = new PoolConfiguration
{
MaxSize = 10,
MinSize = 5
}
}
}
}
};
}
public static DataTable GetRecordsFromCouchBase(int int_Selected_Record_Count)
{
ClusterHelper.Initialize(GetClientConfiguration());
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__19
1.MoveNext()
Source: mscorlib
I have also tried giving the Client Configuration in web.config. But that too has not helped.