-1

I am trying to create a demo on MemCache with multiple servers. I have installed WAMP and XAMPP on my local machine. Wamp can be accessed by localhost and XAMPP can be accessed by localhost:7980.

I have installed Memcache on both servers (correct versions are installed). On both server's phpinfo() shows memcache is installed. My one memcache server port is 11211 and second memcache server port is 11212. I am using yii2 and my configuration is as below.

'cache' => [
        'class' => 'yii\caching\MemCache',
        'servers' => [
            [
                'host' => 'localhost',
                'port' => 11211,
                'weight' => 60,
            ],
            [
                'host' => 'localhost:7980',
                'port' => 11212,
                'weight' => 60,
            ],
        ],
    ],

I am getting below error

MemcachePool::get(): Server localhost:7980 (tcp 11212, udp 0) failed with: Malformed VALUE header (0)

Please guide me where I'm going wrong. Any help will be appreciated.

Curious
  • 93
  • 1
  • 11
  • What version of Memcached does your installation have? Can you connect to two servers if they're not on the same machine? – Scuzzy Oct 05 '18 at 07:32
  • @Scuzzy its `Version 3.0.8` on both servers. – Curious Oct 05 '18 at 07:33
  • found a similar question at https://stackoverflow.com/questions/19299259/using-yii-with-memcache-error-when-one-of-two-server-fails still trying to find anything else. – Scuzzy Oct 05 '18 at 07:35
  • @Scuzzy `useMemcached` is set to `false` in my configuration – Curious Oct 05 '18 at 07:38
  • Are you aware that whilst you may have a _Memcache_ server there are two different PHP libraries to connect to Memcache? Lib [Memcache](http://php.net/manual/en/book.memcache.php) and [Memcached](http://php.net/manual/en/book.memcached.php). Might be worth trying the alternative one to what you're using. – Scuzzy Oct 05 '18 at 08:08
  • @Scuzzy It works when I use the server of port `11211` but not with the `11212` – Curious Oct 05 '18 at 08:31
  • 1
    Wait, your "host" syntax has `:7980` in it, is this unessesary since you then specify `11212` as the port? – Scuzzy Oct 05 '18 at 09:00
  • @Scuzzy If I remove the port `:7980` then I am getting this error: `MemcachePool::get(): Server localhost (tcp 11212, udp 0) failed with: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)` – Curious Oct 05 '18 at 09:09

1 Answers1

1

The problem is fixed by starting the server on a different port. I used below command and it worked. memcached.exe install -p 11212

Curious
  • 93
  • 1
  • 11