Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to use the extension to connect to counchbase server (version 4.0.0-4051) #67

Open
sfabid opened this issue Oct 25, 2019 · 2 comments

Comments

@sfabid
Copy link

sfabid commented Oct 25, 2019

Hi,

I tried the extension and it worked fine with the couchbase server 6.5.0 Enterprise edition. The problem surfaced when I tried connecting to the older couchbase server 4.0.0-4051.

Steps to reproduce:

  1. Create a new dotnet core webapi project.

  2. Add the Couchbase.Extensions.Caching package from nugget package manager.

  3. Go to the startup.cs to configure the Couchbase by doing the following:
    `
    services.AddCouchbase(option =>
    {
    option.Servers = new List
    {
    new Uri("http://couchbaseserverhostname:8091")
    };

         });
    

services.AddDistributedCouchbaseCache("bucketname", opt => {});
4. Goto to the controller where you want the caching to be used and inject the distributed cache and do the caching operation.
public class DistributedCacheController : ControllerBase
{
private readonly IDistributedCache _cache;
public DistributedCacheController(IDistributedCache cache)
{
_cache = cache;
}
[HttpPut]
public IActionResult Update([FromQuery]string key, [FromBody] string item)
{
_cache.SetString(key, JsonConvert.SerializeObject(item));
return Ok(id);
}
}
Note this works fine if I use this in the startup and connect to the couchbase server 6.5.0:
services.AddDistributedCouchbaseCache("bucketname","password", opt => {});
`

Expected result: the item should be added to the cache
Actual result: Gets an exception:
An unhandled exception occurred while processing the request.
BootstrapException: Could not bootstrap - check inner exceptions for details. (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) (Could not bootstrap with CCCP. (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)) (After bootstrapping the nodes list has zero elements indicating that client failed during bootstrapping. Please check the client logs for more information as for why it failed.)
Couchbase.Core.ClusterController.CreateBucketImpl(string bucketName, string password, IAuthenticator authenticator)

SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Couchbase.IO.DefaultConnectionFactory+<>c__0.b__0_0(IConnectionPool p, IByteConverter c, BufferAllocator b)

CouchbaseBootstrapException: After bootstrapping the nodes list has zero elements indicating that client failed during bootstrapping. Please check the client logs for more information as for why it failed.
Couchbase.Configuration.CouchbaseConfigContext.UpdateServices(Dictionary<IPEndPoint, IServer> servers)

SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Couchbase.IO.DefaultConnectionFactory+<>c__0.b__0_0(IConnectionPool p, IByteConverter c, BufferAllocator b)

@MikeGoldsmith
Copy link

Hi @sabiddin

What version of the Couchbase SDK are you using? My initial guess is the SDK is not authenticating with the cluster correctly. RBAC (role based access control) was added in Couchbase Server 5.5 and changed how the SDK goes connection setup.

I can try to test this locally in the next day or two but also note that CB server 4.0 is EoL.

@sfabid
Copy link
Author

sfabid commented Oct 25, 2019

Hi @MikeGoldsmith ,

thanks for the quick response but I am not specifically using any SDK on my local but the server at my workplace that I am trying to connect have the couchbase 4.0.0
image
also, on the side note while trying the extension for my learning purpose I have installed the CB 6.5.0 edition installed on my local. when i connect to the one that is installed locally(6.5.0) the extension works fine as my bucket in CB is password protected. I use the overload with the password argument
services.AddDistributedCouchbaseCache("cachebucket", "password", opt => {});
the problem arises when i try to connect to my workplace' CB(4.0.0) where the bucket is not password protected and I see the exception. also if i look in my output window it fails here:
Exception thrown: 'System.Net.Sockets.SocketException' in Couchbase.NetClient.dll
Couchbase.Configuration.ConfigContextBase:Error: Could not add server XXX.XX.X.X:BucketPortNo. Exception: System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
at Couchbase.IO.DefaultConnectionFactory.<>c__01.<GetGeneric>b__0_0(IConnectionPool1 p, IByteConverter c, BufferAllocator b)
at Couchbase.IO.SharedConnectionPool1.CreateAndAuthConnection() at Couchbase.IO.SharedConnectionPool1.Acquire()
at Couchbase.IO.Services.PooledIOService..ctor(IConnectionPool connectionPool)
at Couchbase.IO.IOServiceFactory.<>c__DisplayClass0_0.b__0(IConnectionPool pool)
at Couchbase.Configuration.ConfigContextBase.CreateIOService(PoolConfiguration poolConfiguration, IPEndPoint endpoint)
at Couchbase.Configuration.CouchbaseConfigContext.LoadConfig()
Exception thrown: 'Couchbase.Configuration.CouchbaseBootstrapException' in Couchbase.NetClient.dll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants