[SOLVED] Ubuntu 13.10 + PHP 5.5.3 + LibCouchBase 2.1.3 + PHP CouchBase Client 1.1.5 (1.1.4dp1) = CouchbaseLibcouchbaseException

Hello Cool CouchBase'ers

We are currently upgrading our CouchBase development machines and installing the lastest version of Ubuntu Desktop (13.10) and applying our usual DevBox configuration management to these machines.

We have noticed some interesting behaviour and are wondering if this has been observed in the labs or on anyone else's server configuration.

Ubuntu 13.10 by default installs the newer version of PHP (PHP Version 5.5.3-1ubuntu1).

We installed the Couchbase PHP SDK client as we normally would using PECL.

sudo pecl install couchbase

Installation goes fine. We find we need to add the recommended lines to php.ini in both the /etc/php5/cli/php.ini and /etc/php5/fpm/php.ini to work around the issue of the couchbase module loading before the json module.

extension=json.so
extension=couchbase.so

Running php -m on the command line produces the json warning, however I can see that the couchbase module has loaded. All is looking mighty fine... until we execute the php code.

When the php code is trying to instantiate the new Couchbase object,
$cb = new Couchbase($node, $account, $password, $bucket, true);
it throws the following error

CouchbaseLibcouchbaseException, 
Failed to create libcouchbase instance.

Output of ldd /usr/lib/php5/20121212/couchbase.so is pasted below.

	linux-vdso.so.1 =>  (0x00007fff66ffe000)
	libcouchbase.so.2 => /usr/lib/libcouchbase.so.2 (0x00007f2936d20000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f2936b07000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f293673f000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f293643b000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2936237000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f2937190000)

I would like to understand the possible cause and too troubleshoot this issue with some help from the cool CouchBase community. We would love to get our development machine onto 5.5.3 of PHP and help anyone else in the future who may be experiencing a similar error.

Can anyone recommend some trouble shooting steps that we could try to get the CouchBase PHP SDK client and the CouchBase C libraries creating a libcouchbase instance object ?

How do you set / check the credentials on a specific bucket? I have a couchbase bucket running on an alternative port (11214) and can't see a way of setting credentials for it other than the global ones. Meanwhile, after updating PHP Couchbase will no longer connect to it and I assume it's due to the above issue. Please help! THanks!!!

1 Answer

« Back to question.

Could you verify that you are using the _exact_ same value for "username" and "bucket". Previous versions of libcouchbase allowed you to connect to the cluster with a different username than the bucket you wanted to use (for instance connect with administrator to operate on bucket "foo"). This isn't something we think is a good practice to use (its similar to log into your unix system as root to su to the user you want to use), so it was decided to deny that usage. Unfortunately the error code (and message) isn't correctly being propagated back to the user in PHP (there is a patch that will be part of the next release of the PHP extension).

Cheers,

Trond

Hi Trondn

Thank you for helping me solve this one.

You are so right!!! I triple checked the credentials I was using and found a mis-match against the buckets credentials vrs the parameters in instantiating the PHP Couchbase object. One small tweak and we have the wonderfully lightning fast flow of data back. I am thinking that as you posted above, we were getting away with using credentials from one bucket that allowed us access to another. ie: We have production, develop, test and default buckets. Appreciate your response in helping us get to the bottom of this. This is running well on our current devbox configuration. Awesome!!

How do you set / check the credentials on a specific bucket? I have a couchbase bucket running on an alternative port (11214) and can't see a way of setting credentials for it other than the global ones. Meanwhile, after updating PHP Couchbase will no longer connect to it and I assume it's due to the above issue. Please help! THanks!!! - See more at: http://www.couchbase.com/communities/q-and-a/solved-ubuntu-1310-php-553-...

Hi Michael

Can you see the web-based administration panel for CouchBase? Can you access this through your web browser on newly configured port? If so, then go to the Data Buckets menu and the click on the arrow at the beginning of the buckets name. This will spin down an inline view of your buckets memory and disk usage. Then click the edit button inline with the bucket name on the RHS. You should now have a pop-up window with an access control section for a password for the bucket. After setting your password, go back to your php code where you instantiate the CouchBase object and triple check your bucket name and password. They must be an exact match for the bucket that you are connecting too. Try this and see how you go. Good Luck. :)

Hi,
Thanks for getting back to me! What you describe is exactly what I was able to find, but it doesn't apply to my situation, as I have a bucket that runs on a dedicated port and therefore is "auth-less", as per the web admin.
Here's how this bucket is configured:
bucket name: bingostats
bucket type: couchbase
access control: dedicated port 11214

In the past I was able to connect to this bucket with PHP Couchbase using the global username and password to Couchbase (the same ones I use to log in to the web console). Now I can't. Since updating libcouchbase I can only access my default bucket without any user/pass, and none of my named buckets and authless buckets.
So back to the bucket above, I used to instantiate Couchbase like this:

$cb = new Couchbase('127.0.0.1:8091', $global_cb_user, $global_cb_pass, "bingostats"); 

This now throws the exception. By the way, in case you're wondering about the dedicated port, I use that to also connect to this bucket via a memcache client.

What am I doing wrong or am I misunderstanding? How do I instantiate PHP Couchbase to connect to this bucket, taking the info I just gave you into account?

Thanks!

Michael, can you try the following...

$cb = new Couchbase('127.0.0.1:11214', $global_cb_user, $global_cb_pass, "bingostats"); 

This is instantiating the PHP CouchBase object that should give you a successful result when you then try and retrieve a document using the object. Try this with your previous username + password and also try with empty strings just as a test.

$cb = new Couchbase('127.0.0.1:11214', "", "", "bingostats"); 

It maybe that the bucket was never configured with a username and password, only the cluster node was.

What ended up working is the bottom suggestion, ie. port 11214 and empty strings for username and password. I'm a bit confused, and don't think I've seen anything in the docs that suggested this should even work:

  • Why post 11214? I thought that all couchbase connections went through 8091? Originally I was able to access this bucket over 8091, even though it had the same access control settings.
  • You say: It maybe that the bucket was never configured with a username and password, only the cluster node was ... I created the bucket via the web console. At no point was I asked to provide a username and password for or, nor could I set one after the fact. So is my bucket now permanently unauthenticated?

Thanks a lot for your help! Really much appreciated. Would still love a follow up re my questions/comments above. Thanks!! :)

Also worth noting that instantiating against port 11214 and empty user/pass is NOT WORKING against older version of libcouchbase / couchbase server. Ie. I have a CB server on my local dev machine with a "bingostats" bucket configured EXACTLY the same way as the one on the server I describe above (where I upgraded libcouchbase and CB server), and changing the connection params to port 11214 and using empty auth params is NOT working... It seems like you (inadvertently?) released a breaking change without any notice or documentation?

You're doing it "almost" right. Your bucket is listening to that special port, but you're not supposed to specify the bucket port at the connect address to the constructor. Try changing your code to:

$cb = new Couchbase("127.0.0.1", "", "", "bingostats");

That seemed to have worked, thank you trond! I still think these changes have not been properly documented. In no way is it clear in the example that you're not supposed to pass credentials, I think it shows examples WITH the port, etc. Moreover, all this was working fine for years until this week it broke with a libcouchbase update... It should have started with deprecation notices prior to making it a breaking change.

Yes, I see your point, and we should definitively have more documentation around this area. I guess part of the problem in the documentation is that it is only in the libcouchbase documentation we stated that one should use the least privilege principle and authenticate with the bucket credentials (and when you don't have any credentials for the bucket they should then be empty etc). We'll try to get this addressed as soon as possible. In the next release of the php extension you will get a better error message as well (which is another part of the problem).

Sorry for the inconvenience.