1

I have RHEL6.1 with php. I've installed libmemcached-1.0.2 from src.rpm and compiled php-memcached 2.0.0b2. If I try to setSaslAuthData('user','pass') and write something to memcached (Couchbase server) I always end up with return code 5 (WRITE FAILURE). Commenting setSaslAuthData out turns to work with default bucket. But I need to get it working with SASL. Any ideas on what's wrong with my setup?

P.S. of course binary protocol is ON

Dmytro Leonenko
  • 456
  • 1
  • 7
  • 24

2 Answers2

1

Are you sure memcached is compiled with sasl?

$ memcached -S

You should see this output if memcached wasn't compiled with SASL: "This server is not built with SASL support."

ckliborn
  • 2,778
  • 4
  • 25
  • 37
  • It's not memcached in clear form. As I said it's CouchBase Server (v2.0 DP). It uses memcachable protocol. PHP [native realization](https://github.com/ronnywang/PHPMemcacheSASL) works just fine – Dmytro Leonenko Dec 07 '11 at 08:55
1

When you setup a bucket you can provide a password. Then use SASL to connect to Couchbase Server by using the name of the bucket as username and the password you provided earlier.

Extended, 2011-12-11

I've been reading the source of the memcached extension. Generally, it seems like they are not too many things you can do wrong on the PHP side.

Additional questions:

  • Can you make sure no other errors are exposed in the PHP error_log? E.g. "Failed to initialize SASL library." or something like that?
  • Did you set memcached.use_sasl = 1 in your php.ini?
  • Did you check Couchbase Server's log for errors when you try to set a key?

I'm not an expert on Couchbase Server though I know my way around CouchDB. In case you have to debug it, I'd try to figure out how to crank up the log level to something like DEBUG and then see if you can gather any useful information.

I think unless it's one of the first two things then this error is not on the PHP side but maybe in the Couchbase Server release. It looks like the write error is something libmemcached exposes so this means that it's coming from Couchbase Server directly.

Till
  • 1,019
  • 6
  • 14
  • How does it answer to my question? I was doing exactly what you've said with result I described – Dmytro Leonenko Dec 09 '11 at 12:55
  • You did not share how got the information which you used to connect to Couchbase. You said you used a username and password and I didn't know where you got that from. Pretty harsh to downvote this and it doesn't make me want to help you further. – Till Dec 09 '11 at 18:52
  • As I wrote in comment to ckliborn's answer many days ago SASL works with native PHP implementation. And of course I know that backet name is username than. – Dmytro Leonenko Dec 11 '11 at 17:45
  • 1. No any errors on PHP side. Exact error description for error code 5 I got by modifying source code of extension to write error desc. to log file, because error code 5 could mean other things also. 2. "memcached.use_sasl = 1". No, haven't set it. I'll try and update original post. 3. Couchbase log is almost empty on authentication. So no, no any errors. I think the problem may be on php-memcached side as I can connect successfully with native [PHP implementation](https://github.com/ronnywang/PHPMemcacheSASL). – Dmytro Leonenko Dec 12 '11 at 09:56
  • But maybe problem is really on couchbase server side as their implementation of extension to communicate with couchbase server disables sasl part for some reason. Their extension is based on the same php-memcached extension which again relay on libmemcached – Dmytro Leonenko Dec 12 '11 at 10:35
  • CouchDB and memcache have different loglevels – maybe you can set "debug", somewhere? – Till Dec 12 '11 at 20:12
  • I'll try to figure out that – Dmytro Leonenko Dec 13 '11 at 13:02