Php sdk 3.0 lcb_err_protocol_error

i’ve recently updrgaded on eof our PHP service to the latest client PHP SDK 3.0 connecting to couchbase enterprise 6.0.3 - whilst this works perfectly in a local dev environment with couchbase 6.0.3 installed I cannot get it to connect when deployed to our staging environement I get the following error:

[Mon Jun 01 11:08:13.929969 2020] [php7:notice] [pid 16] [client hidden_ip_address:36106] [cb,WARN] (cccp L:383 I:3249826512) <10-253-156-175.cb-d2c-nonprod-srv.db.svc.cluster.local:11210> (CTX=0x55a93ee64ab0,bc_cccp) CCCP Packet responded with 0x8; nkey=0, nbytes=45, cmd=0xb5, seq=0xf00d
[Mon Jun 01 11:08:13.930022 2020] [php7:notice] [pid 16] [client hidden_ip_address:36106] [cb,EROR] (cccp L:171 I:3249826512) <10-253-156-175.cb-d2c-nonprod-srv.db.svc.cluster.local:11210> (CTX=0x55a93ee64ab0,bc_cccp) Could not get configuration: LCB_ERR_PROTOCOL_ERROR (1050)
[Mon Jun 01 11:08:13.930081 2020] [php7:notice] [pid 16] [client hidden_ip_address:36106] [cb,WARN] (cccp L:176 I:3249826512) <NOHOST:NOPORT> (CTX=(nil),) Failed to bootstrap using CCCP
[Mon Jun 01 11:08:13.930098 2020] [php7:notice] [pid 16] [client hidden_ip_address:36106] [cb,EROR] (htconfig L:364 I:3249826512) Not scheduling HTTP provider since no nodes have been configured for HTTP bootstrap
[Mon Jun 01 11:08:13.930107 2020] [php7:notice] [pid 16] [client hidden_ip_address:36106] [cb,EROR] (bootstrap L:196 I:3249826512) Failed to bootstrap client=0x55a93ee3f530. Error=LCB_ERR_CONNECT_ERROR (1051), Message=No more bootstrap providers remain
[Mon Jun 01 11:08:13.930121 2020] [php7:notice] [pid 16] [client hidden_ip_address:36106] [cb,EROR] (pcbc/pool L:104) Failed to bootstrap LCB connection: LCB_ERR_CONNECT_ERROR (1051). I=0x55a93ee3f530

i’ve ran the sdk-dockor within the same connecting machine and it says everything is ok - few warnings outlined below but no errors:

Summary:
[WARN] The hostname specified in your connection string resolves both for SRV records, as well as A records.  This is not suggested as later DNS configuration changes could cause the wrong servers to be contacted
[WARN] Bootstrap host `hidden_ip_address.cb-d2c-nonprod-srv.db.svc.cluster.local` is not using the canonical node hostname of `cb-d2c-nonprod-0016.cb-d2c-nonprod.db.svc`.  This is not neccessarily an error, but has been known to result in strange and challenging to diagnose errors when DNS entries are reconfigured.
[WARN] Bootstrap host `hidden_ip_address.cb-d2c-nonprod-srv.db.svc.cluster.local` is not using the canonical node hostname of `cb-d2c-nonprod-0014.cb-d2c-nonprod.db.svc`.  This is not neccessarily an error, but has been known to result in strange and challenging to diagnose errors when DNS entries are reconfigured.
[WARN] Bootstrap host `hidden_ip_address.cb-d2c-nonprod-srv.db.svc.cluster.local` is not using the canonical node hostname of `cb-d2c-nonprod-0015.cb-d2c-nonprod.db.svc`.  This is not neccessarily an error, but has been known to result in strange and challenging to diagnose errors when DNS entries are reconfigured.

*i’ve hidden the ip addresses.

I think my colleague @avsej can probably weigh in with something on that response sent, but one quick question: can you give us your anonymized connstr and a quick description of the configuration? We see the error output without seeing the bootstrap input at the moment.

Could you try it with DNS-SRV disabled?

<?php

$options = new \Couchbase\ClusterOptions();
$options->credentials("Administrator", "password");
$cluster = new \Couchbase\Cluster("couchbase://localhost?dnssrv=off", $options);                                                                                                                                                               

$bucket = $cluster->bucket("default");
$collection = $bucket->defaultCollection();

$res = $collection->upsert("foo", "bar");
var_dump($res);

Thanks @avsej that seems to work and I can upsert a value into th bucket, but now if I try and run any query using $cluster->query() I immediately get a segmentation fault. bucket is completely new nothing else in it.

$options = new ClusterOptions();
$options->credentials(getenv('COUCHBASE_USER'), getenv('COUCHBASE_PASSWORD'));
$cluster = new Cluster(getenv('COUCHBASE_CONNECTION_STRING'), $options);

$bucket = $cluster->bucket(getenv('COUCHBASE_BUCKET'));
$collection = $bucket->defaultCollection();

$res = $collection->upsert("foo", "bar"); //works!
$res1 = $cluster->query("select * from `default`"); //segmentation fault

What is the version of php-couchbase extension?

i’ve tried both https://packages.couchbase.com/clients/php/couchbase-3.0.0.tgz and https://packages.couchbase.com/clients/php/couchbase-3.0.2.tgz they both result in the same outcome.
running the php docker container php:7.4.6-apache-buster

Hi, @nytram. Sorry for delayed reply. I’ve just tried php:7.4.6-apache-buster with 3.0.2 and it does not crash, just returns the error (if primary index does not exist on the default bucket), or actual result from the query. Could you try to run the script under gdb, and post backtrace here?

To run gdb in docker, you need to give it more permissions:

docker run --cap-add=ALL --cap-add=SYS_ADMIN -ti --rm php:7.4.6-apache-buster /bin/bash

Install dependencies:

apt update && apt install -y curl vim gnupg2 gdb
curl https://packages.couchbase.com/clients/c/repos/deb/couchbase.key | apt-key add -
echo "deb https://packages.couchbase.com/clients/c/repos/deb/debian10 buster buster/main" > /etc/apt/sources.list.d/couchbase.list
apt update
apt-get install -y libcouchbase3 libcouchbase-dev libcouchbase3-tools libcouchbase-dbg libcouchbase3-libev libcouchbase3-libevent

Install the extension

curl -O https://packages.couchbase.com/clients/php/couchbase-3.0.2.tgz
tar xf couchbase-3.0.2.tgz
cd couchbase-3.0.2
phpize && ./configure && make -j8 && make install

Create test file somewhere in /tmp/test.php

<?php

$options = new \Couchbase\ClusterOptions();
$options->credentials('Administrator', 'password');
$cluster = new \Couchbase\Cluster('couchbase://192.168.42.4', $options);

$bucket = $cluster->bucket('default');
$collection = $bucket->defaultCollection();

$res = $collection->upsert("foo", "bar"); //works!
$res1 = $cluster->query("select * from `default`"); //segmentation fault
var_dump($res1);

And now run php under debugger:

gdb /usr/local/bin/php

And execute the script:

(gdb) run -d extension=couchbase  /tmp/test.php

If it crash, you can use backtrace gdb command to print out the stacktrace, and it will help up to figure out what has happened.