Question

I'm having trouble connecting to a Memcached server running on localhost from Dalli. I have been using Dalli with the Memcachier Heroku add-on for a while without any problems though I don't have any experience running Memcached locally.

I downloaded memcached with homebrew and it seems to have installed without a problem. I'm running it like this:

memcached -l 127.0.0.1 -p 11211 -vv

I can connect to the server and query it with

telnet 127.0.0.1 11211

The verbose output of memcached logs all the requests, so I know it's running fine. However, I'm unable to run it with Dalli. I am trying to connect like this:

require 'dalli'
dc = Dalli::Client.new('127.0.0.1:11211')
dc.set('foo', 123)

After I run the last command, Dalli unfailingly spits out

Dalli::RingError: No server available
 from /Users/mac/.rvm/gems/ruby-1.9.3-p392/gems/dalli-2.6.4/lib/dalli/ring.rb:45:in     `server_for_key'
 from /Users/mac/.rvm/gems/ruby-1.9.3-p392/gems/dalli-2.6.4/lib/dalli/client.rb:347:in `perform'
 from /Users/mac/.rvm/gems/ruby-1.9.3-p392/gems/dalli-2.6.4/lib/dalli/client.rb:199:in `set'

... so I'm getting this connection error, but I don't know why. Here's the weird part: Memcached is receiving the request, but it never succeeds in connecting. The following two lines are spit out by the verbose output whenever I try to connect:

<6 new client connection
<6 connection closed.

So what's going on here? Is this an authentication thing? Am I forgetting a command-line option?

EDIT: Figured out what was going on -- I was doing everything right except I was using the builtin version of Memcached. Installed the latest version and everything was fine.

Was it helpful?

Solution

Pretty simple issue, actually: I was just using an out-of-date Memcached version. No idea why that breaks Dalli, but installing a new Memcached fixed it.

OTHER TIPS

That breaks dalli because dalli uses the newer binary memcached protocol instead of the older text-only protocol.

It does this for performance, but unfortunately makes dalli unusable with versions older than memcached 1.4

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top