LSMCD socket port question

gilles

Active Member
#1
I am experimenting with LSMCD and configure it to use a unix socket:
#CACHED.ADDR=127.0.0.1:11211
CACHED.ADDR=UDS:///tmp/lsmcd/lsmcd.sock
When trying to connect through the LSCache plugin, I tried to set port as 0 as advised in the documentation but that did not work. Somehow setting to the port to 11211 (which is the standard port when not using a unix socket) made the connection test pass.

Displaying the getServerList() output looks like this:
array(1) { [0]=> array(3) { ["host"]=> string(21) "/tmp/lsmcd/lsmcd.sock" ["port"]=> int(11211) ["type"]=> string(6) "SOCKET" } }
even though I am not specifying any port in the config file.
 

lsqtwrk

Administrator
#6
that ONLY apply to when you use it on unix socket connection

when you use TCP/IP connection , port must be set 11211 or defined port


full context

If you will be using LSMCD entirely within a single machine and do not need it to listen on a IP port, you can specify a UNIX Domain Socket file name for extra security. For example, using the socket name /tmp/lsmcd.sock specify: Cached.Addr=UDS:///tmp/lsmcd.sock If you are using UNIX domain sockets, see your memcached language guide for connecting to it. For example, for PHP, you specify the domain socket file name as the first parameter (hostName) to addServer and a 0 as the second parameter (port).
 

gilles

Active Member
#7
I am using a unix socket and the necessary port for LSMCD is still 11211 in my case. 0 is correct for Redis, haven't tried memcached.
 

lsqtwrk

Administrator
#8
huh ?

in LSCWP side , you must set to 0

in LSMCD side , I just run a test , whenever I set

CACHED.ADDR=127.0.0.1:11211
CACHED.ADDR=UDS:///tmp/lsmcd.sock


the port 11211 will no longer be available


Code:
[root@test ~]# grep -i cached.addr /usr/local/lsmcd/conf/node.conf
CACHED.ADDR=127.0.0.1:11211
CACHED.ADDR=UDS:///tmp/lsmcd.sock
[root@test ~]# systemctl restart lsmcd
[root@test ~]# netstat -lnp | grep lsmcd
unix  2      [ ACC ]     STREAM     LISTENING     1693579  23528/./bin/lsmcd    //tmp/lsmcd.sock
[root@test ~]# netstat -lnp | grep 11211
[root@test ~]#
 

gilles

Active Member
#11
Well I cannot reproduce the issue anymore. Now whatever port I use when the socket is selected does not seem to matter at all (which would make more sense).

Any idea why getServerList() reported the port as 11211:
array(1) { [0]=> array(3) { ["host"]=> string(21) "/tmp/lsmcd/lsmcd.sock" ["port"]=> int(11211) ["type"]=> string(6) "SOCKET" } }
for the socket, even though I have it nowhere specified in my node.conf file?
 

gilles

Active Member
#13
The one from the documentation:
Code:
<?php

    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);

    $conn = new Memcached ;
    $address = '/tmp/lsmcd/lsmcd.sock' ; // set the address here
    $port = 0; // set the port
    $conn->addServer( $address, $port ) ;
    var_dump( $address ) ;
    var_dump( $port ) ;
    var_dump( $conn->getStats() ) ;
    echo '<hr>';
    var_dump($conn->getServerList());
?>
Note I have an extra lsmcd subdirectory under /tmp.
 
Top