سؤال

I tried a simple test with memcached from jelastic and always getting the exception "COnnection refused"... But the URL ist correct. Is some add

    MemcachedClient c = new MemcachedClient(
            new InetSocketAddress("memcached-myexample.jelastic.dogado.eu", 11211));

    c.set("someKey", 3600, user);

    User cachedUser = (User) c.get("someKey");

Here is the exception:

2014-01-02 00:07:41.820 INFO net.spy.memcached.MemcachedConnection:  Added {QA sa=memcached-myexample.jelastic.dogado.eu/92.51.168.106:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2014-01-02 00:07:41.833 WARN net.spy.memcached.MemcachedConnection:  Could not redistribute to another node, retrying primary node for someKey.
2014-01-02 00:07:41.835 WARN net.spy.memcached.MemcachedConnection:  Could not redistribute to another node, retrying primary node for someKey.
2014-01-02 00:07:41.858 INFO net.spy.memcached.MemcachedConnection:  Connection state changed for sun.nio.ch.SelectionKeyImpl@2dc1482f
2014-01-02 00:07:41.859 INFO net.spy.memcached.MemcachedConnection:  Reconnecting due to failure to connect to {QA sa=memcached-myexample.jelastic.dogado.eu/92.51.168.106:11211, #Rops=0, #Wops=2, #iq=0, topRop=null, topWop=Cmd: set Key: someKey Flags: 1 Exp: 3600 Data Length: 149, toWrite=0, interested=0}
java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:735)
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:629)
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:409)
    at net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:1334)
هل كانت مفيدة؟

المحلول

I would try to telnet to your memcached cluster in order to rule out a firewall issue. You can do that with the following command.

telnet memcached-myexample.jelastic.dogado.eu 11211

If that doesn't work then you have network issues. If this is the case I would first check to see if you have a firewall up.

نصائح أخرى

Add int portNum = 11211; at the first, and try again.

int portNum = 11211;
MemcachedClient c = new MemcachedClient(
new InetSocketAddress("memcached-myexample.jelastic.dogado.eu", portNum));

// Store a value (async) for one hour
c.set("someKey", 3600, someObject);
// Retrieve a value (synchronously).
Object myObject=c.get("someKey");

Thanks but the error was on a firewall rule from the provider. So not my failure.

Check /etc/memcached.conf file and update the server IP address from which you want to access the cache.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top