Connecting to 6.0.0 Community with Python SDK3.0.0b3

Hi. I’m having a lot of trouble connecting to my instance in Python, but cbc works perfectly on the CLI. Here’s what I’ve got right now:

cluster = Cluster.connect(args.cluster,
                      ClusterOptions(PasswordAuthenticator(**COUCHBASE_CREDS)))

And COUCHBASE_CREDS is just a dictionary like this:

{'username': 'foo', 'password': 'bar'}

I get this error:

Traceback (most recent call last):
  File "couchbase_load.py", line 31, in <module>
    ClusterOptions(PasswordAuthenticator(**COUCHBASE_CREDS)))
  File "/usr/local/lib/python3.7/dist-packages/couchbase/cluster.py", line 261, in connect
    return Cluster(connection_string, *options, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/couchbase/cluster.py", line 254, in __init__
    self._authenticate(authenticator)
  File "/usr/local/lib/python3.7/dist-packages/couchbase/cluster.py", line 274, in _authenticate
    self.admin = Admin(auth.get('username'), auth.get('password'), connstr=str(self.connstr))
  File "/usr/local/lib/python3.7/dist-packages/couchbase/management/admin.py", line 98, in __init__
    self._connect()
    couchbase.exceptions.BucketMissingException: 
      <RC=0xD2[LCB_ERR_BUCKET_NOT_FOUND (210)], 
      There was a problem while trying to send/receive your request over the 
      network. This may be a result of a bad network or a misconfigured client 
      or server, C Source=(src/bucket.c,1200)>

My connection string is “couchbase://couchbase”, and the name couchbase is DNS resolvable in my LAN. I can ping it just fine and this name works with cbc.

Please help!

Hi, it sounds like it’s connecting but having trouble connecting to the cluster in ‘Cluster’ mode.

This sounds a little like a known issue which we are working on: https://issues.couchbase.com/browse/PYCBC-800, but please could you try:

pip install https://github.com/couchbase/couchbase-python-client.git

And let us know if this still happens.

Also, try export LCB_LOGLEVEL=5 before running the code, and send the output.

Thanks,

Ellis

Alright, I installed from the git repo. The command above didn’t work but this did:

pip install git+git://github.com/couchbase/couchbase-python-client

Here’s the output:

0ms [I3d4d34cbed6489ff] {1689} [INFO] (instance - L:509) Version=3.0.0_beta3_22_ge6c11d180c, Changeset=e6c11d180c94abb576f8d5bba616d76e744f0583
0ms [I3d4d34cbed6489ff] {1689} [INFO] (instance - L:510) Effective connection string: couchbase://couchbase. Bucket=default
15ms [I3d4d34cbed6489ff] {1689} [INFO] (instance - L:202) DNS SRV lookup failed: LCB_ERR_UNKNOWN_HOST (1049). Ignore this if not relying on DNS SRV records
15ms [I3d4d34cbed6489ff] {1689} [DEBUG] (instance - L:139) Adding host couchbase:8091 to initial HTTP bootstrap list
15ms [I3d4d34cbed6489ff] {1689} [DEBUG] (instance - L:139) Adding host couchbase:11210 to initial CCCP bootstrap list
15ms [I3d4d34cbed6489ff] {1689} [TRACE] (instance - L:182) Bootstrap hosts loaded (cccp:1, http:1)
15ms [I3d4d34cbed6489ff] {1689} [INFO] (bootstrap - L:259) Requested network configuration: heuristic
15ms [I3d4d34cbed6489ff] {1689} [DEBUG] (confmon - L:92) Preparing providers (this may be called multiple times)
15ms [I3d4d34cbed6489ff] {1689} [DEBUG] (confmon - L:99) Provider CCCP is ENABLED
15ms [I3d4d34cbed6489ff] {1689} [DEBUG] (confmon - L:99) Provider HTTP is ENABLED
15ms [I3d4d34cbed6489ff] {1689} [TRACE] (confmon - L:299) Refreshing current cluster map
15ms [I3d4d34cbed6489ff] {1689} [TRACE] (confmon - L:285) Attempting to retrieve cluster map via CCCP
15ms [I3d4d34cbed6489ff] {1689} [INFO] (cccp - L:160) Requesting connection to node couchbase:11210 for CCCP configuration
15ms [I3d4d34cbed6489ff] {1689} [DEBUG] (lcbio_mgr - L:481) <couchbase:11210> (HE=0x14104d0) Creating new connection because none are available in the pool
15ms [I3d4d34cbed6489ff] {1689} [TRACE] (lcbio_mgr - L:393) <couchbase:11210> (HE=0x14104d0) New pool entry: I=0x12e8900
15ms [I3d4d34cbed6489ff] {1689} [INFO] (connection - L:487) <couchbase:11210> (SOCK=292479d06aa4dd7e) Starting. Timeout=2000000us
17ms [I3d4d34cbed6489ff] {1689} [DEBUG] (connection - L:252) <couchbase:11210> (SOCK=292479d06aa4dd7e) Created new socket with FD=3
17ms [I3d4d34cbed6489ff] {1689} [TRACE] (connection - L:352) <couchbase:11210> (SOCK=292479d06aa4dd7e) Scheduling I/O watcher for asynchronous connection completion.
18ms [I3d4d34cbed6489ff] {1689} [INFO] (connection - L:155) <couchbase:11210> (SOCK=292479d06aa4dd7e) Connected established
18ms [I3d4d34cbed6489ff] {1689} [DEBUG] (connection - L:108) <couchbase:11210> (SOCK=292479d06aa4dd7e) Successfully set TCP_NODELAY
18ms [I3d4d34cbed6489ff] {1689} [DEBUG] (connection - L:108) <couchbase:11210> (SOCK=292479d06aa4dd7e) Successfully set TCP_KEEPALIVE
18ms [I3d4d34cbed6489ff] {1689} [DEBUG] (lcbio_mgr - L:349) <couchbase:11210> (HE=0x14104d0) Received result for I=0x12e8900,C=(nil); E=0x0
18ms [I3d4d34cbed6489ff] {1689} [DEBUG] (lcbio_mgr - L:309) <couchbase:11210> (HE=0x14104d0) Assigning R=0x12b3af0 SOCKET=0x14170d0
18ms [I3d4d34cbed6489ff] {1689} [DEBUG] (ioctx - L:95) <couchbase:11210> (CTX=0x13dfe50,unknown) Pairing with SOCK=292479d06aa4dd7e
18ms [I3d4d34cbed6489ff] {1689} [DEBUG] (negotiation - L:433) <couchbase:11210> (CTX=0x13dfe50,sasl,SASLREQ=0x140bed0) HELO identificator: {"a":"libcouchbase/3.0.0_beta3_22_ge6c11d180c (Linux-4.19.0-8-amd64; x86_64; GNU 8.3.0)","i":"3d4d34cbed6489ff/292479d06aa4dd7e"}, features: 0x02 (TLS), 0x06 (XATTR), 0x0b (JSON), 0x08 (Select bucket), 0x07 (XERROR), 0x03 (TCP nodelay), 0x0a (Snappy), 0x04 (Mutation seqno), 0x0f (Tracing), 0x12 (Collections)
19ms [I3d4d34cbed6489ff] {1689} [DEBUG] (negotiation - L:464) <couchbase:11210> (CTX=0x13dfe50,sasl,SASLREQ=0x140bed0) Server supports features: 0x03 (TCP nodelay), 0x04 (Mutation seqno), 0x06 (XATTR), 0x07 (XERROR), 0x08 (Select bucket), 0x0a (Snappy), 0x0b (JSON)
34ms [I3d4d34cbed6489ff] {1689} [DEBUG] (ioctx - L:140) <couchbase:11210> (CTX=0x13dfe50,sasl) Destroying context. Pending Writes=0, Entered=true, Socket Refcount=1
34ms [I3d4d34cbed6489ff] {1689} [DEBUG] (ioctx - L:95) <couchbase:11210> (CTX=0x15f6ab0,unknown) Pairing with SOCK=292479d06aa4dd7e
35ms [I3d4d34cbed6489ff] {1689} [WARN] (cccp - L:383) <couchbase:11210> (CTX=0x15f6ab0,bc_cccp) CCCP Packet responded with 0x8; nkey=0, nbytes=42, cmd=0xb5, seq=0xf00d
35ms [I3d4d34cbed6489ff] {1689} [ERROR] (cccp - L:171) <couchbase:11210> (CTX=0x15f6ab0,bc_cccp) Could not get configuration: LCB_ERR_PROTOCOL_ERROR (1050)
35ms [I3d4d34cbed6489ff] {1689} [DEBUG] (ioctx - L:140) <couchbase:11210> (CTX=0x15f6ab0,bc_cccp) Destroying context. Pending Writes=0, Entered=true, Socket Refcount=1
35ms [I3d4d34cbed6489ff] {1689} [WARN] (cccp - L:176) <NOHOST:NOPORT> (CTX=(nil),) Failed to bootstrap using CCCP
35ms [I3d4d34cbed6489ff] {1689} [INFO] (confmon - L:195) Provider 'CCCP' failed: LCB_ERR_PROTOCOL_ERROR (1050)
35ms [I3d4d34cbed6489ff] {1689} [DEBUG] (confmon - L:239) Will try next provider in 0us
35ms [I3d4d34cbed6489ff] {1689} [TRACE] (confmon - L:285) Attempting to retrieve cluster map via HTTP
36ms [I3d4d34cbed6489ff] {1689} [TRACE] (htconfig - L:359) Starting HTTP Configuration Provider 0x1450090
36ms [I3d4d34cbed6489ff] {1689} [INFO] (connection - L:487) <couchbase:8091> (SOCK=a1a3933bbaedb852) Starting. Timeout=2000000us
36ms [I3d4d34cbed6489ff] {1689} [DEBUG] (connection - L:252) <couchbase:8091> (SOCK=a1a3933bbaedb852) Created new socket with FD=3
36ms [I3d4d34cbed6489ff] {1689} [TRACE] (connection - L:352) <couchbase:8091> (SOCK=a1a3933bbaedb852) Scheduling I/O watcher for asynchronous connection completion.
38ms [I3d4d34cbed6489ff] {1689} [INFO] (connection - L:155) <couchbase:8091> (SOCK=a1a3933bbaedb852) Connected established
38ms [I3d4d34cbed6489ff] {1689} [DEBUG] (connection - L:108) <couchbase:8091> (SOCK=a1a3933bbaedb852) Successfully set TCP_NODELAY
38ms [I3d4d34cbed6489ff] {1689} [DEBUG] (connection - L:108) <couchbase:8091> (SOCK=a1a3933bbaedb852) Successfully set TCP_KEEPALIVE
38ms [I3d4d34cbed6489ff] {1689} [DEBUG] (htconfig - L:315) Successfuly connected to REST API couchbase:8091
38ms [I3d4d34cbed6489ff] {1689} [DEBUG] (ioctx - L:95) <couchbase:8091> (CTX=0x14f7fb0,unknown) Pairing with SOCK=a1a3933bbaedb852
43ms [I3d4d34cbed6489ff] {1689} [TRACE] (htconfig - L:212) <couchbase:8091> (CTX=0x14f7fb0,bc_http) Received 411 bytes on HTTP stream
43ms [I3d4d34cbed6489ff] {1689} [WARN] (htconfig - L:133) <couchbase:8091> (CTX=0x14f7fb0,bc_http) Got 404 on config stream. Assuming terse URI not supported on cluster
46ms [I3d4d34cbed6489ff] {1689} [TRACE] (htconfig - L:212) <couchbase:8091> (CTX=0x14f7fb0,bc_http) Received 411 bytes on HTTP stream
46ms [I3d4d34cbed6489ff] {1689} [ERROR] (htconfig - L:121) <couchbase:8091> (CTX=0x14f7fb0,bc_http) Got 404 on config stream. Assuming bucket does not exist as we've tried both URL types
46ms [I3d4d34cbed6489ff] {1689} [ERROR] (htconfig - L:146) <couchbase:8091> (CTX=0x14f7fb0,bc_http) Got non-success HTTP status code 404
46ms [I3d4d34cbed6489ff] {1689} [DEBUG] (ioctx - L:140) <couchbase:8091> (CTX=0x14f7fb0,bc_http) Destroying context. Pending Writes=0, Entered=true, Socket Refcount=1
46ms [I3d4d34cbed6489ff] {1689} [INFO] (confmon - L:195) Provider 'HTTP' failed: LCB_ERR_BUCKET_NOT_FOUND (210)
46ms [I3d4d34cbed6489ff] {1689} [TRACE] (confmon - L:244) Maximum provider reached. Resetting index
46ms [I3d4d34cbed6489ff] {1689} [ERROR] (bootstrap - L:196) Failed to bootstrap client=0x1458400. Error=LCB_ERR_BUCKET_NOT_FOUND (210), Message=No more bootstrap providers remain
{'username': 'archive', 'password': 'password'}
Traceback (most recent call last):
  File "couchbase_load.py", line 31, in <module>
    ClusterOptions(PasswordAuthenticator(**COUCHBASE_CREDS)))
  File "/home/archive/.local/lib/python3.7/site-packages/couchbase/cluster.py", line 294, in connect
    return Cluster(connection_string, *options, **kwargs)
  File "/home/archive/.local/lib/python3.7/site-packages/couchbase/cluster.py", line 280, in __init__
    self._authenticate(authenticator)
  File "/home/archive/.local/lib/python3.7/site-packages/couchbase/cluster.py", line 307, in _authenticate
    self.admin = Admin(auth.get('username'), auth.get('password'), connstr=str(self.connstr))
  File "/home/archive/.local/lib/python3.7/site-packages/couchbase/management/admin.py", line 98, in __init__
    self._connect()
couchbase.exceptions.BucketMissingException: <RC=0xD2[LCB_ERR_BUCKET_NOT_FOUND (210)], There was a problem while trying to send/receive your request over the network. This may be a result of a bad network or a misconfigured client or server, C Source=(src/bucket.c,1200)>

Any advice? I’m hoping to be able to at least work around this soon.

Well since I haven’t heard back, I went back to the old way:

thing_bucket = Bucket(f"{args.cluster}/{args.thing_bucket}", **COUCHBASE_CREDS)

I guess this as good as we can do for now.

Apologies for the delay in response - looks like it’s looking for a ‘default’ bucket which possibly doesn’t exist. Will take a look today - thanks.

Any progress? I’m experiencing the same problem Using 6.0.0 and 3.0.0:

>>> cluster
<couchbase_core.client.Cluster bucket=, nodes=['xxx.xxx.xxx.xxx:8091', 'xxx.xxx.xxx.xxx:8091', 'xxx.xxx.xxx.xxx:8091'] at 0x7f7d990f0208>
>>> bucket = cluster.bucket('mybucket')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib64/python3.6/site-packages/couchbase/cluster.py", line 480, in bucket
    return self._cluster.open_bucket(name, admin=self._admin)
  File "/usr/local/lib64/python3.6/site-packages/couchbase/cluster.py", line 465, in _admin
    self.__admin = Admin(connection_string=str(self.connstr), **self._adminopts)
  File "/usr/local/lib64/python3.6/site-packages/couchbase/management/admin.py", line 101, in __init__
    self._connect()
couchbase.exceptions.BucketNotFoundException: <RC=0xD2[LCB_ERR_BUCKET_NOT_FOUND (210)], There was a problem while trying to send/receive your request over the network. This may be a result of a bad network or a misconfigured client or server, C Source=(src/bucket.c,1209)>

No such problem using SDK 2.5.11 against the same server performing the same task.

Hi, apologies again for not getting back to you sooner.
This looks like https://issues.couchbase.com/browse/PYCBC-918 which was resolved recently.
The fix is available if you install from git:

pip install https://github.com/couchbase/couchbase-python-client.git

It will be included in the next release 3.0.1 with is currently scheduled for next week.

Please let us know how you get on.

Thanks,

Ellis

This has solved my issue. Thanks for the effort and looking forward to the official release.

1 Like

Glad to be of service!