2017-02-08 4 views
0

J'essaye de me connecter à Redis Cloud Memcached mais je reçois une erreur (ci-dessous). J'ai vérifié que le nom d'utilisateur, le mot de passe, l'hôte et le port sont corrects dans l'interface apps.redislabs.com. Je peux me connecter si je désactive SASL et me connecte sans authentification.Comment s'authentifier auprès de Redis Cloud Memcached à partir de Spymemcached?

Comment puis-je diagnostiquer cela?

(à l'aide spymemcached 2.11.6.)

import net.spy.memcached.auth.*; 
import net.spy.memcached.*; 
... 
List<InetSocketAddress> addresses = Collections.singletonList(addr); 
AuthDescriptor ad = new AuthDescriptor(new String[] { "CRAM-MD5", "PLAIN" }, 
     new PlainCallbackHandler(user, password)); 
MemcachedClient mc = new MemcachedClient(new ConnectionFactoryBuilder() 
     .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) 
     .setAuthDescriptor(ad).build(), 
AddrUtil.getAddresses(host + ":" + port)); 

Le stacktrace:

net.spy.memcached.MemcachedConnection: Added {QA sa=pub-memcache-14154.us-central1-1-1.gce.garantiadata.com/104.197.191.74:14514, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue 
net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl: Discarding partially completed op: SASL auth operation 
net.spy.memcached.MemcachedConnection: Reconnecting due to exception on {QA sa=pub-memcache-14154.us-central1-1-1.gce.garantiadata.com/104.197.191.74:14514, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=1} 
java.io.IOException: An existing connection was forcibly closed by the remote host 
    at sun.nio.ch.SocketDispatcher.read0(Native Method) 
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) 
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) 
    at sun.nio.ch.IOUtil.read(IOUtil.java:192) 
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) 
    at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:820) 
    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:1446) 
net.spy.memcached.MemcachedConnection: Closing, and reopening {QA sa=pub-memcache-14154.us-central1-1-1.gce.garantiadata.com/104.197.191.74:14514, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=1}, attempt 0. 
net.spy.memcached.MemcachedConnection: Could not redistribute to another node, retrying primary node for foo. 

Répondre

3

perdent la "CRAM-MD5" dans votre déclaration AuthDescriptior.

Les travaux suivants dans mes tests: (utilisateur, passer, et url supprimé)

AuthDescriptor ad = new AuthDescriptor(new String[] {"PLAIN"}, new PlainCallbackHandler(user, pass)); 
MemcachedClient mc = null; 
    try { 
     mc = new MemcachedClient(
     new ConnectionFactoryBuilder() 
      .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) 
      .setAuthDescriptor(ad).build(), 
     AddrUtil.getAddresses(host + ":" + port)); 
    } catch (IOException e) { 
     // handle exception 
    } 
mc.set("foo", 0, "bar"); 
String value = (String) mc.get("foo"); 
System.out.println(value); 
+0

L'OP aurait dû communiquer avec le soutien de Redis Labs ... oh, je vois tout le monde est ici de toute façon;) –

+0

qui a fait il! Est-ce que l'utilisation de PLAIN réduit la sécurité? –