Memcached getStats not working with Couchbase

Basically I had the same problem as this thread

And I am using php 5.5.27 memcached 2.20, libmemcached 1.0.16, Couchbase 3.1.0. (memcached client received server version is 2.1.1).

I had no problem with setting and retrieving key and value. But getStats just return false when I am connecting to couchbase.

But getStats is works prefectly fine with Memcached server…

What port have you configured your memcached client to connect to?

If it’s the standard memcached port 11211 (or another custom port - i.e. anything not 11210 then you’ll be connecting to the Couchbase cluster via the moxi memcached proxy. Moxi will return stats from the Couchbase Server in the original form, which at a guess is not in the format that the legacy memcached client expects.

While Couchbase Server does support using vanilla memcached clients for normal Key/Value operations, you may want to use a native client to take full advantage of Couchbase Servers’ capabilities. See the Deployment Strategies page for more details.

Thanks for your reply!

I am connecting to Couchbase via 11212, so it via the moxi memcached proxy.
I tried to change the Couchbase’s memcached bucket port to 11210, but it gave me port in use error…
nestat tell me memcached is listen to the port 11210, but when I kill the memcached process, Couchbase server becomes down and pending.
So I guess the port 11210 is always listen by Couchbase?
I tried to connect the port 11210 with Memcached, but the connection cannot be made.
With telnet I could connect to the port, but using stats command it just frozen.

And what are the Native Client? Do you mean using the Couchbase PHP SDK?
I tried do:
$cbc = new \CouchbaseCluster(“http://localhost:11212”);
$bucket = $cbc->openBucket(‘My-Bucket’);
It gave me:
ErrorException [ Fatal Error ]:
Uncaught exception ‘Fuel\Core\PhpErrorException’ with message ‘file([CouchbaseNative]/CouchbaseBucket.class.php): failed to open stream: No such file or directory’

Yes, port 11210 is the standard Couchbase port for SASL-authenticated buckets. You will need to use a smart SDK (e.g. PDP SDK 2.0) to access Couchbase on that port.

Try changing to port 11210.

I tried both port 11210 and 11212 with the above code, but I still get the same exception fail on openBucket:

Uncaught exception ‘Fuel\Core\PhpErrorException’ with message ‘file([CouchbaseNative]/CouchbaseBucket.class.php): failed to open stream: No such file or directory’ in /home/ec2-user/webapps/rest_api/fuel/core/classes/debug.php:324

By the way, I just notice I could connect to the defined memcached bucket ‘My-Bucket’ with port 8091 instead of either 11210 and 11212. Even though the memcached bucket port is configured as 11212.
Bucket Settings
Bucket Type: Memcached
Access Control: Dedicated port (supports ASCII portocol and is auth-less) Protocol port: 11212

But I guess I am not connecting to the memcached bucket in the right way you mentioned.

Ah yes - I’d forgotten the 2.0 PHP SDK uses the main admin port (8091) to bootstrap the connection. You should be fine using that port in your code.

1 Like

@drigby
So in summary:

  • When using smart SDK (e.g. PHP SDK) Couchbase’s memcached bucket uses 8091 (Nothing to do with the port I assigned)
  • When using vanilla memcached clients I have to connect via Moxi Memcached Proxy (with the port I assigned to the memcached bucket). And since 11210 is not available or reachable, so I guess no way for getStats() works for vanilla memcached clients?