Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

Connection issues with Couchbase PHP Extension, Couchbase 1.8.1

7 replies [Last post]
  • Login or register to post comments
Fri, 12/07/2012 - 14:02
alex m
Offline
Joined: 12/07/2012
Groups: None

The servers are currently using v1.0.0 of the PHP Couchbase extension, and couchbase 1.8.1 community edition, build 937, on CentOS 5.4. In the logs, I frequently see these two types of errors:

Couchbase::__construct(): Failed to connect libcouchbase to server: Connection failure, referer: myniftyurlhere.com

Couchbase::get(): Faild to get a value from server: Operation timed out

We didn't have these issues with Memcached and Client-side Moxi. So I've begun testing Memcached & Client-side Moxi (1.8) to talk to the cluster. Unfortunately, when using the Memcached extension to read those values, I encounter this error:

$connection = new Memcached;
$connection->addServer('localhost', 11211);
$connection->get('testKey'); // saved using couchbase extension
print_r($connection->getResultMessage());
 
> Warning: Memcached::get(): could not decompress value in /test-script.php
> PAYLOAD FAILURE

Interestingly, if I use netcat to talk on port 11211 to the client moxi, I get this:

[root@test ~]# echo 'get testKey' | nc localhost 11211
VALUE testKey 6 19
hello! @ 1354913089
END

Of course, reading the values using the existing PHP couchbase extension works. Oddly enough, when I compile and install Couchbase extension v1.0.6, or use the precompiled Centos 5.5 version, it also has a similar complaint:

Warning: Couchbase::get(): unknown payload type in test.php on line 8
Warning: Couchbase::get(): Failed to get a value from server: Generic error in test.php on line 8

What's the best way to address the connection errors? Should we be using client-side moxi? If so, what is the Couchbase extension using to compress the values such that Memcached cannot uncompress them? If not, how can I begin diagnosing the possible reasons why the Couchbase client can't connect to/read values from the Couchbase cluster?

Top
  • Login or register to post comments
Tue, 12/11/2012 - 10:04
alex m
Offline
Joined: 12/07/2012
Groups: None

I was able to diagnose the issue. There haven't been any responses, but this may be helpful to others who have to make this change. I noticed that there's no documentation for this breaking change.

For non-scalar datatypes(and possibly more, I've only tested with serialized data), Couchbase PHP Extensions 1.0.0-1.0.2 (maybe earlier) save different flags using the memcache set command than in later versions. In the memcached protocol, you can optionally save flags and have them be read by the client. If you get the unknown payload type error, in the prompt type:

$ echo 'get testKey' | nc $SERVER_SIDE_MOXI_URL 11211
VALUE testKey 31 19
O:8:"stdClass":0:{}
END

The number after testKey indicates the flags the value was saved with. It should be 4, not 31, to be read by later versions of the Couchbase PHP extension.

Top
  • Login or register to post comments
Wed, 12/12/2012 - 02:27
daschl
Offline
Joined: 05/19/2012
Groups: None

Hi alex,

if you can, upgrade to the previously released 1.1 version: It is compatible with 1.8, has lots of enhancements and bugfixes and should allow you to move to 2.0:

http://www.couchbase.com/develop/php/current

Thanks,
Michael

Top
  • Login or register to post comments
Wed, 12/12/2012 - 02:34
trond
trond's picture
Offline
Joined: 03/15/2010
Groups: None

The Couchbase 1.1.0 version of the php extension use a setting compatible with the memcached extension.

Top
  • Login or register to post comments
Wed, 12/12/2012 - 09:47
alex m
Offline
Joined: 12/07/2012
Groups: None

Hi, thanks for the responses,

This is somewhat unrelated, but I had a question about the documentation. I was under the impression that when set to true, the php extension will maintain a connection between calls to the interpreter. However, in the documentation there's this line:

"The Couchbase library has limited functionality for connecting to servers; it does not directly support vBuckets or SASL authentication. You can, however, configure multiple servers with associated weights (connection priorities) by specifying hostname, port and weight. One solution is to use client-side Moxi to act as a proxy service to the Couchbase Server cluster."

This seems to imply that it doesn't. What are the pros and cons of using client-side moxi versus using the couchbase php extension with regards to performance?

Just to be clear, this is a cluster that is always been using couchbase server & php extension.

Top
  • Login or register to post comments
Thu, 12/13/2012 - 00:28
trond
trond's picture
Offline
Joined: 03/15/2010
Groups: None

alex m wrote:
Hi, thanks for the responses,

This is somewhat unrelated, but I had a question about the documentation. I was under the impression that when set to true, the php extension will maintain a connection between calls to the interpreter. However, in the documentation there's this line:

"The Couchbase library has limited functionality for connecting to servers; it does not directly support vBuckets or SASL authentication. You can, however, configure multiple servers with associated weights (connection priorities) by specifying hostname, port and weight. One solution is to use client-side Moxi to act as a proxy service to the Couchbase Server cluster."

This seems to imply that it doesn't. What are the pros and cons of using client-side moxi versus using the couchbase php extension with regards to performance?

Just to be clear, this is a cluster that is always been using couchbase server & php extension.

I haven't looked at the documentation lately, but it seems to me that it is a bit obsolete. The PHP extension is built on top of libcouchbase which supports vbuckets and SASL authentication. Unless you specify the perisitent connection features you're going to end up connecting to the cluster, retrieve the cluster information, do SASL authentication to the correct bucket and get your data _EVERY_ time causing the performance to drop significantly. Do you have a link to where you found that piece in the documentation so I can file a bug for it to be updated?

Top
  • Login or register to post comments
Thu, 12/13/2012 - 08:04
alex m
Offline
Joined: 12/07/2012
Groups: None

Thanks, trond. The link is here: http://www.couchbase.com/docs/couchbase-sdk-php-1.1/couchbase-sdk-php-tu...

I was able to get persistent connections with the 1.0.6 extension. I did try to upgrade to 1.1.0 (I compiled from source), but ended up getting this error upon connection:

Couchbase::__construct(): failed to create IO instance error

Still, we met the goal of getting persistent connections working. The old 1.0.1 extension would segfault frequently when using it.

Top
  • Login or register to post comments
Thu, 12/13/2012 - 08:45
trond
trond's picture
Offline
Joined: 03/15/2010
Groups: None

alex m wrote:
Thanks, trond. The link is here: http://www.couchbase.com/docs/couchbase-sdk-php-1.1/couchbase-sdk-php-tu...

I was able to get persistent connections with the 1.0.6 extension. I did try to upgrade to 1.1.0 (I compiled from source), but ended up getting this error upon connection:

Couchbase::__construct(): failed to create IO instance error

Still, we met the goal of getting persistent connections working. The old 1.0.1 extension would segfault frequently when using it.

Where did you install the library? please note that the couchbase php plugin tries to open the libcouchbase_XXX (libevent/libev plugin) so those modules need to be in the search path for the runtime linker from PHP...

You could try to just copy them to /usr/lib and see if that resolves your problem (Or build libcouchbase with -Wl,rpath,/path/to/your/installation/lib/dir)

Hope this helps

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker