php-memcached-dev / php-memcached

memcached extension based on libmemcached library
Other
990 stars 323 forks source link

When using sasl return false #533

Open wiryonolau opened 1 year ago

wiryonolau commented 1 year ago

Using sasl always return false, even when the log said it's authenticated. Anything missing ? without sasl it works normally

PHP environment

memcached support => enabled
libmemcached version => 1.0.18
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.default_binary_protocol => Off => Off
memcached.default_connect_timeout => 0 => 0
memcached.default_consistent_hash => Off => Off
memcached.serializer => igbinary => igbinary
memcached.sess_binary_protocol => On => On
memcached.sess_connect_timeout => 0 => 0
memcached.sess_consistent_hash => On => On
memcached.sess_consistent_hash_type => ketama => ketama
memcached.sess_lock_expire => 0 => 0
memcached.sess_lock_max_wait => not set => not set
memcached.sess_lock_retries => 5 => 5
memcached.sess_lock_wait => not set => not set
memcached.sess_lock_wait_max => 150 => 150
memcached.sess_lock_wait_min => 150 => 150
memcached.sess_locking => On => On
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_persistent => Off => Off
memcached.sess_prefix => memc.sess.key. => memc.sess.key.
memcached.sess_randomize_replica_read => Off => Off
memcached.sess_remove_failed_servers => Off => Off
memcached.sess_sasl_password => no value => no value
memcached.sess_sasl_username => no value => no value
memcached.sess_server_failure_limit => 0 => 0
memcached.store_retry_count => 0 => 0

Memcached

Run using memcached -u memcached -p 11211 -v -S -vvvv

memcached.conf contain

mech_list: plain
sasldb_path: /opt/bitnami/memcached/conf/sasl2/memcachedsasldb

PHP script

$m = new Memcached();
$m->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_IGBINARY);
$m->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$m->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$m->setSaslAuthData("user", "password");
$m->addServer("memcached", 11211, 0) or die("Cannot connect");

// Return empty string
print_r($m->getVersion());

// Return empty string
echo $m->set("test", "test", 3600);

// Return empty string
echo $m->get("test");

Memcached Log

<24 new binary client connection.
24: going from conn_new_cmd to conn_waiting
24: going from conn_waiting to conn_read
24: going from conn_read to conn_parse_cmd
<24 Read binary protocol data:
<24    0x80 0x20 0x00 0x00
<24    0x00 0x00 0x00 0x00
<24    0x00 0x00 0x00 0x00
<24    0x00 0x02 0x00 0x00
<24    0x00 0x00 0x00 0x00
<24    0x00 0x00 0x00 0x00
authenticated() in cmd 0x20 is true
>24 Writing bin response:
>24   0x81 0x20 0x00 0x00
>24   0x00 0x00 0x00 0x00
>24   0x00 0x00 0x00 0x05
>24   0x00 0x02 0x00 0x00
>24   0x00 0x00 0x00 0x00
>24   0x00 0x00 0x00 0x00
24: going from conn_parse_cmd to conn_new_cmd
24: going from conn_new_cmd to conn_mwrite
24: going from conn_mwrite to conn_new_cmd
24: going from conn_new_cmd to conn_waiting
24: going from conn_waiting to conn_read
24: going from conn_read to conn_closing
<24 connection closed.