twitter / twemproxy

A fast, light-weight proxy for memcached and redis
Apache License 2.0
12.13k stars 2.06k forks source link

Failed to connect to twenproxy using spymemcached #331

Closed icexelloss closed 9 years ago

icexelloss commented 9 years ago

Hi,

I am trying to connect to twemproxy using spymemcached, but there is some issue, here is the log from my test program:

2015-03-12 16:12:38.681 INFO net.spy.memcached.MemcachedConnection:  Added {QA sa=my_memcached_server/172.21.96.244:31212, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
null

2015-03-12 16:12:38.739 INFO net.spy.memcached.MemcachedConnection:  Added {QA sa=my_twemproxy_server/172.21.97.98:22121, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2015-03-12 16:12:38.746 WARN net.spy.memcached.MemcachedConnection:  Could not redistribute to another node, retrying primary node for key1.
2015-03-12 16:12:38.758 INFO net.spy.memcached.MemcachedConnection:  Reconnecting due to exception on {QA sa=my_twemproxy_server/172.21.97.98:22121, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: get Keys: key1Exp: 0, topWop=null, toWrite=0, interested=1}
java.io.IOException: Disconnected unexpected, will reconnect.
    at net.spy.memcached.MemcachedConnection.handleReadsWhenChannelEndOfStream(MemcachedConnection.java:911)
    at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:823)
    at net.spy.memcached.MemcachedConnection.handleReadsAndWrites(MemcachedConnection.java:720)
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:683)
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:436)
    at net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:1445)
2015-03-12 16:12:38.760 WARN net.spy.memcached.MemcachedConnection:  Closing, and reopening {QA sa=my_twemproxy_server/172.21.97.98:22121, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: get Keys: key1Exp: 0, topWop=null, toWrite=0, interested=1}, attempt 0.
2015-03-12 16:12:38.761 WARN net.spy.memcached.protocol.ascii.AsciiMemcachedNodeImpl:  Discarding partially completed op: Cmd: get Keys: key1Exp: 0
Exception in thread "main" java.util.concurrent.CancellationException: Cancelled
    at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:177)
    at net.spy.memcached.internal.GetFuture.get(GetFuture.java:69)
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1230)
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1257)
    at com.twosigma.accelfs.Test.main(Test.java:50)
2015-03-12 16:12:40.762 INFO net.spy.memcached.MemcachedConnection:  Reconnecting {QA sa=my_twemproxy_server/172.21.97.98:22121, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}

Here is the example code:

       final String key = "key1";
       MemcachedClient memcache1 = new MemcachedClient(new InetSocketAddress("my_memcached_server", 31212));
       System.out.println(memcache1.get(key));

       MemcachedClient memcache2 = new MemcachedClient(new InetSocketAddress("my_twemproxy_server", 22121));

       System.out.println(memcache2.get(key));
       System.exit(0);

Can someone shed some light on this? Should I use another java memcached library?

Version: spymemcached 2.11.5 twemproxy 0.4.0

manjuraj commented 9 years ago

twemproxy only supports ascii memcache protocol. you need to configure your client library to use ascii protocol

icexelloss commented 9 years ago

Thanks for the quick reply. It does look like spymemcached is using asii already:

2015-03-12 16:12:38.761 WARN net.spy.memcached.protocol.ascii.AsciiMemcachedNodeImpl:  Discarding partially completed op: Cmd: get Keys: key1Exp: 0
Exception in thread "main" java.util.concurrent.CancellationException: Cancelled
    at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:177)
    at net.spy.memcached.internal.GetFuture.get(GetFuture.java:69)
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1230)
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1257)
    at com.twosigma.accelfs.Test.main(Test.java:50)
icexelloss commented 9 years ago

Nvm. It turns out to be a configuration mistake on my side. Sorry guys.

emonmishra commented 6 years ago

@icexelloss can you explain what was the configuration mistake ? I am also getting same error