I’m trying with CouchbaseNetClient SDK version 2.7.2 and latest version in.net core application but no success. when i’m accessing from URL 127.0.0.1:8091 or localhost:8091 its working fine. Below is code for your ref.
In startup.cs using 2.7.2 SDK version:
ClusterHelper.Initialize(new ClientConfiguration
{
Servers = new List { new Uri(Configuration.GetSection(“Couchbase”)[“Servers”]) }
},
new PasswordAuthenticator(Configuration.GetSection(“Couchbase”)[“UserName”],Configuration.GetSection(“Couchbase”)[“Password”]));
Controller code:
private readonly IBucket _bucket;
public MerchantController(IBucketProvider bucketProvider)
{
_bucket = bucketProvider.GetBucket("demo");
}
also trying with this code:
ClientConfiguration obj = new ClientConfiguration();
obj.ConfigurationProviders = ServerConfigurationProviders.HttpStreaming;
var config = new ClientConfiguration
{
// assign one or more Couchbase Server URIs available for bootstrap
Servers = new List<Uri>
{
new Uri(Config.GetSection("Couchbase")["Servers"])
},
BucketConfigs = new Dictionary<string, BucketConfiguration> {
{"demo", new BucketConfiguration {
PoolConfiguration = new PoolConfiguration {
MaxSize = 6,
MinSize = 4,
SendTimeout = 12000
},
Port = 8091,
DefaultOperationLifespan = 123,
Username = Config.GetSection("Couchbase")["UserName"],
Password = Config.GetSection("Couchbase")["Password"],
BucketName = "demo"
}}},
UseSsl = false,
};
ClusterHelper.Initialize(config);
Controller code:
private readonly IBucket _bucket;
public MerchantController(IBucketProvider bucketProvider)
{
_bucket = bucketProvider.GetBucket("demo");
}
also trying with this:using Couchbase.Extensions.DependencyInjection;
services.AddCouchbase(x=> { x.ConnectionString = Config.GetSection(“Couchbase”)[“Servers”];
x.Username = Config.GetSection(“Couchbase”)[“UserName”];
x.Password = Config.GetSection(“Couchbase”)[“Password”];
}
);
Controller code:
private readonly IBucket _bucket;
public MerchantController(IBucketProvider bucketProvider)
{
_bucket = bucketProvider.GetBucket("demo");
}
Kindly help for connecting Couchbase connection after port forwarding.