I’ve been trying to connect to Couchbase Capella using the example shown in the Connect option in the cluster. I’m using Python 3.9, Docker, Django 4.0, and Couchbase 4.0.5 in a macOS. And the following error is being visible. Moreover, I’ve kept my allowed IPs to 0.0.0.0.
gdmp-core | Traceback (most recent call last):
gdmp-core | File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py", line 55, in inner
gdmp-core | response = get_response(request)
gdmp-core | File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/base.py", line 197, in _get_response
gdmp-core | response = wrapped_callback(request, *callback_args, **callback_kwargs)
gdmp-core | File "/usr/local/lib/python3.10/dist-packages/django/views/generic/base.py", line 103, in view
gdmp-core | return self.dispatch(request, *args, **kwargs)
gdmp-core | File "/usr/local/lib/python3.10/dist-packages/django/views/generic/base.py", line 142, in dispatch
gdmp-core | return handler(request, *args, **kwargs)
gdmp-core | File "/app/user/views.py", line 9, in get
gdmp-core | return JsonResponse(user.connect(), safe=False)
gdmp-core | File "/app/core/database/couchbase.py", line 39, in connect
gdmp-core | cluster = Cluster('couchbases://{}'.format(host), ClusterOptions(authenticator=auth, enable_tls=True))
gdmp-core | File "/usr/local/lib/python3.10/dist-packages/couchbase/cluster.py", line 99, in __init__
gdmp-core | self._connect()
gdmp-core | File "/usr/local/lib/python3.10/dist-packages/couchbase/logic/wrappers.py", line 101, in wrapped_fn
gdmp-core | raise e
gdmp-core | File "/usr/local/lib/python3.10/dist-packages/couchbase/logic/wrappers.py", line 85, in wrapped_fn
gdmp-core | ret = fn(self, *args, **kwargs)
gdmp-core | File "/usr/local/lib/python3.10/dist-packages/couchbase/cluster.py", line 105, in _connect
gdmp-core | raise ErrorMapper.build_exception(ret)
gdmp-core | couchbase.exceptions.UnAmbiguousTimeoutException: <ec=14, category=couchbase.common, message=unambiguous_timeout (14), C Source=/home/ec2-user/workspace/python/sdk/python-manylinux-wheel-pipeline/couchbase-python-client/src/connection.cxx:199>
Hi @ab.mon421 - I would suggest you try increasing some of the timeouts. It is possible that default timeouts can be too short when using a development environment across the internet. I should note that in production the expectation is deployment in the same region. I have provided some snippets below. I hope this helps.
Basic use of ClusterTimeoutOptions.
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
endpoint = '--your-instance--.dp.cloud.couchbase.com'
username = 'username'
password = 'password'
bucket_name = 'bucketname'
# not needed w/ 4.x SDK
# cert_path = 'path/to/certificate'
# User Input ends here.
auth = PasswordAuthenticator(username, password)
timeout_opts = ClusterTimeoutOptions(connect_timeout=timedelta(seconds=20),
kv_timeout=timedelta(seconds=20))
cluster = Cluster('couchbases://{}'.format(endpoint),
ClusterOptions(auth, timeout_options=timeout_opts))
cb = cluster.bucket(bucket_name)
cb_coll = cb.scope('inventory').collection('airline')
# get a reference to the default collection, required for older Couchbase server versions
cb_coll_default = cb.default_collection()
Use of newer Configuration Profile feature (we currently have one geared specifically to WAN development).
# 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,
KnownConfigProfiles,
QueryOptions)
# Update this to your cluster
endpoint = '--your-instance--.dp.cloud.couchbase.com'
username = 'username'
password = 'password'
bucket_name = 'bucketname'
# not needed w/ 4.x SDK
# cert_path = 'path/to/certificate'
# User Input ends here.
auth = PasswordAuthenticator(username, password)
opts = ClusterOptions.create_options_with_profile(auth, KnownConfigProfiles.WanDevelopment)
cluster = Cluster('couchbases://{}'.format(endpoint), opts)
cb = cluster.bucket(bucket_name)
cb_coll = cb.scope('inventory').collection('airline')
# get a reference to the default collection, required for older Couchbase server versions
cb_coll_default = cb.default_collection()
Hi @plmsmansit - Could you provided more information? The following is usually a helpful start:
Provide the version of the Python SDK are you using
Provide details on your environment (Operating System, Python Version, etc)
Provide a small code example that demonstrates the issue
Provide DEBUG level logs of the issue. If using SDK 4.1.0, you should be able to run the following command (using your script). If using an earlier version, see the logging docs for setup.