Python 4.1.1 SDK and connecting to Servers with version less than 6.6

I am trying to connect to a couchbase cluster running on version < 6.6 and I am getting this error while using python SDK

Code:

from datetime import timedelta

# needed for any cluster connection
from couchbase.auth import PasswordAuthenticator
from couchbase.cluster import Cluster
# needed for options -- cluster, timeout, SQL++ (N1QL) query, etc.
from couchbase.options import (ClusterOptions, ClusterTimeoutOptions,
                               QueryOptions)

# Update this to your cluster
username = "The actual user"
password = "The correct password"
bucket_name = "The_Bucket"
# User Input ends here.

# Connect options - authentication
auth = PasswordAuthenticator(
    username,
    password,
)

# Get a reference to our cluster
# NOTE: For TLS/SSL connection use 'couchbases://<your-ip-address>' instead
cluster = Cluster('couchbase://abc.test.com', ClusterOptions(auth))

# get a reference to our bucket
cb = cluster.bucket(bucket_name)

# Wait until the cluster is ready for use.
cluster.wait_until_ready(timedelta(seconds=5))

Error:

AuthenticationException                   Traceback (most recent call last)
<ipython-input-15-9443e614a719> in <module>
     23 # Get a reference to our cluster
     24 # NOTE: For TLS/SSL connection use 'couchbases://<your-ip-address>' instead
---> 25 cluster = Cluster('couchbase://abc.test.com', ClusterOptions(auth))
     26 
     27 # get a reference to our bucket

/idn/home/user/venv/test/test1/lib/python3.7/site-packages/couchbase/cluster.py in __init__(self, connstr, *options, **kwargs)
     97 
     98         super().__init__(connstr, *options, **kwargs)
---> 99         self._connect()
    100 
    101     @BlockingWrapper.block(True)

/idn/home/user/test/test1/ve_magics/lib/python3.7/site-packages/couchbase/logic/wrappers.py in wrapped_fn(self, *args, **kwargs)
     99                         e._message = ('If using Couchbase Server < 6.6, '
    100                                       'a bucket needs to be opened prior to cluster level operations')
--> 101                     raise e
    102                 except Exception as ex:
    103                     exc_cls = PYCBC_ERROR_MAP.get(ExceptionMap.InternalSDKException.value, CouchbaseException)

/idn/home/user/test/test1/ve_magics/lib/python3.7/site-packages/couchbase/logic/wrappers.py in wrapped_fn(self, *args, **kwargs)
     83             def wrapped_fn(self, *args, **kwargs):
     84                 try:
---> 85                     ret = fn(self, *args, **kwargs)
     86                     if isinstance(ret, BaseCouchbaseException):
     87                         raise ErrorMapper.build_exception(ret)

/idn/home/user/test/test1/ve_magics/lib/python3.7/site-packages/couchbase/cluster.py in _connect(self, **kwargs)
    103         ret = super()._connect_cluster(**kwargs)
    104         if isinstance(ret, BaseCouchbaseException):
--> 105             raise ErrorMapper.build_exception(ret)
    106         self._set_connection(ret)
    107 

AuthenticationException: <ec=6, category=couchbase.common, message=authentication_failure (6). Possible reasons: incorrect authentication configuration, bucket doesn't exist or bucket may be hibernated., C Source=/home/ec2-user/workspace/python/sdk/python-manylinux-wheel-pipeline/couchbase-python-client/src/connection.cxx:199>

Any suggestions ?

The issue is happening if the username is like this “svc.testid”. If I give the bucket user, it is going through

Hi @himanshu.mps - This seems like an environment issue. Are you sure the credentials are correct? There should not be a problem with a user name of “svc.testid” if that user exists. Also, what do you mean by “bucket user”? Also, it might be beneficial to provide logs (PYCBC_LOG_LEVEL=debug python3 ).

The issue was because the user was ldap user and we had to change the connection string to specify ldap authentication

So you needed to use PasswordAuthenticator’s static ldap_compatible() method? Just want to make sure other users can see what the solution was.

I created the cluster connection this way

cluster = Cluster('couchbase://cluster.com?sasl_mech_force=PLAIN', ClusterOptions(auth))