1

I just setup memcached on a ubuntu system i have on my network. Didn't change any options so everything is default. I think tried to connect to the server using Enyim. It doesn't fail but when i try to retrieve the items they are always null. I'm not much of a low level won't but i've been able to discern things from wireshark before so i decided to give it a try. I'haven't been able to discern anything but i noticed the first .Store() command i sent actually sent network packets to the correct address. Every .Store() command did absolutely nothing.

Here is my app.config:

I've tried both "Binary" & "Text" Protocols and they did the same thing.

Here is my c# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Enyim.Caching;
using Enyim.Caching.Configuration;
using Enyim.Caching.Memcached;

namespace MemCacheTest
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //var config = new MemcachedClientConfiguration();
            //config.Servers.Add(new IPEndPoint(new IPAddress(new byte[] {10, 0, 0, 1}), 11211));
            //config.Protocol = MemcachedProtocol.Binary;

            var mc = new MemcachedClient();
            for (var i = 0; i < 100; i++)
               mc.Store(StoreMode.Set, "Hello", "World");
            mc.Store(StoreMode.Set, "MyKey", "Hello World");
            Console.WriteLine(mc.Get("MyKey"));
            Console.WriteLine("It should have failed!!!");

            Console.ReadLine();

        }

    }
}

Does anyone know whats going on or how i could determine what is wrong? I thought it was strange that i wasn't getting any exceptions so i set an invalid ip address in the config file. Same results.

4

2 に答える 2

1

The short answer: If your service is running check your port, it should be blocked somehow. (did you add an exception for port 11211 in Ubuntu firewall(iptables)?)

telnet 10.0.0.1 11211 If you have a telnet client on your server this will show the port is inaccessible.

Enyim doesn't throw you an error even the port is inaccessible. yes, it's strange.

于 2012-11-29T08:57:50.243 に答える
1

To add to dasun answer. When you install memcached by default its configured to only listen on the "lo/localhost" interface. Its the only security memcache really has. Even if you try to telnet locally and do specify the lo interface for example:

telnet 10.0.0.1 11211

it will fail. To fix you have to go into the memcached.conf file and comment out

# -l 127.0.0.1 

and then restart the service

于 2012-11-30T04:35:12.733 に答える