Memcache connects but does not respond to any command

Setting: Apache; PHP 5.2.9; libevent (required for memcached) version 1.3; memcached server version 1.2.2 (tried 1.4.5, 1.4.0, now downgraded to 1.2.2, there is no difference); Memcached php pecl module version 2.2.6.

Problem:

Like unsolved problems cannot store values ​​in memcache and Super strange PHP error

None of these threads resolved the problem, and none of the authors of the questions complied with the recommendations given. I followed them and it still does not work.

Memcache code does not show any errors if I connect via PHP, but as soon as I try to execute any command (for example, getVersion ), I get the answer:

Notice: memcache_get_version() [function.memcache-get-version]: Server 127.0.0.1 (tcp 11211) failed with: Failed reading line from stream (0) in /var/www/html/memcache.php on line 11

Solutions:

Connecting to memcache via the command line does not work. After I type any command connection, it closes.

 [/usr/local/src]$ telnet 127.0.0.1 11211 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. stats Connection closed by foreign host. 

I tried $ memcached -S to make sure memcached was compiled with SASL support disabled. Answer: "This server is not built with SASL support."

In addition, one of the comments was

You may be using memcached without ASCII protocol support, for example, if you ran:

  $ memcached -B binary 

If so, remove the -B argument entirely and both PHP and telnet should work.

Memcache start line:

 memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 

There is no argument B in it.

Any ideas?

+2
source share
2 answers

To whom it may be interesting.

The problem is resolved.

That's where the problem is (maybe this would help authors from 2 related treads).

On shared hosting, sometimes you should not use 127.0.0.1. Use the site’s IP address instead.

So changing

 memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 

to

 memcached -d -m 1024 -u root -l 123.456.789.123 -p 11211 

and php code from

 $memcache->pconnect("127.0.0.1",11211); 

to

 $memcache->pconnect("123.456.789.123",11211); 

fixed problem.

Thanks everyone!

+5
source

I will talk with your sys sadmin. I think there might be a firewall.

0
source

All Articles