SASL Authentication via spymemcached(2.11.7) client failing to Couchbase(3.0.1) memcached buckets

352 views
Skip to first unread message

Calvin Chen

unread,
Jan 26, 2016, 2:02:14 PM1/26/16
to Couchbase
Hi all,

Have been stuck for the past day trying to figure out why the spymemcached client(2.11.7) packaged within simple-spring-memcached(3.6.0) is failing to authenticate with the following spymemcached configuration.  Upon running the unit test yesterday, it did however spontaneously connect once yesterday but since then has been looping through the same auth failure.  I'm positive that the Couchbase server is running and is reachable via the example below which uses class configuration.  I'm thinking this has to do with something in my xml config that's flaking, any assistance is much appreciated.

Sample class configuration used to validate connection.

@Bean
    @DependsOn("cacheBase")
    public CacheFactory cacheFactory() {
        CacheFactory cacheFactory = new CacheFactory();
        cacheFactory.setCacheName("memcached_bucket_name");
        cacheFactory.setCacheClientFactory(new MemcacheClientFactoryImpl());

        String server = SERVER;
        if (StringUtils.isEmpty(server)) {
            server = environment.getProperty("cache.server");
        }

        SpymemcachedConfiguration cacheConfiguration = createCacheConfiguration(server);
        cacheFactory.setAddressProvider(new DefaultAddressProvider(server));
        cacheFactory.setConfiguration(cacheConfiguration);

        return cacheFactory;
    }
 
    private SpymemcachedConfiguration createCacheConfiguration(final String server) {
        SpymemcachedConfiguration cacheConfiguration = new SpymemcachedConfiguration();
        cacheConfiguration.setConsistentHashing(true);
        cacheConfiguration.setUseBinaryProtocol(true);

        AuthDescriptor authDescriptor = new AuthDescriptor(new String[]{"PLAIN"}, new PlainCallbackHandler("memcached_bucket_name", "password234243"));
        cacheConfiguration.setAuthDescriptor(authDescriptor);

        return cacheConfiguration;
    }


This is the spring configuration which I'm using that's failing for me.
<spring-config.xml>

<bean name="defaultMemcachedClient" class="com.google.code.ssm.CacheFactory">

    <property name="cacheClientFactory">

      <bean name="cacheClientFactory" class="com.google.code.ssm.providers.spymemcached.MemcacheClientFactoryImpl" />

    </property>

    <property name="addressProvider">

      <bean class="com.google.code.ssm.config.DefaultAddressProvider">

        <property name="address" value="xxx.xx.x.xxx:11211,xxx.xx.x.xxx:11211,xxx.xx.x.xxx:11211"/>

      </bean>

    </property>

    <property name="configuration">

    <bean class="com.google.code.ssm.providers.spymemcached.SpymemcachedConfiguration">

        <property name="operationTimeout" value="10000" />  

        <property name="useBinaryProtocol" value="true" />  

        <property name="failureMode" value="Redistribute"/>

        <property name="hashAlg">

<value type="net.spy.memcached.DefaultHashAlgorithm">KETAMA_HASH</value>

</property>

        <property name="locatorType" value="CONSISTENT"/>

    <property name="authDescriptor">

        <bean class="net.spy.memcached.auth.AuthDescriptor">

            <constructor-arg index="0">

                <value>PLAIN</value>

            </constructor-arg>

            <constructor-arg index="1">

                <bean class="net.spy.memcached.auth.PlainCallbackHandler">

                    <constructor-arg index="0">

                        <value>"memcached_bucket_name"</value>

                    </constructor-arg>

                    <constructor-arg index="1">

                        <value>"password123123"</value>

                    </constructor-arg>

                </bean>

            </constructor-arg>

        </bean>

        </property>

        </bean>

    </property>



2016-01-26 09:31:00.788 ERROR net.spy.memcached.protocol.binary.SASLAuthOperationImpl:  Error:  Auth failure
2016-01-26 09:31:00.789 WARN net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl:  Discarding partially completed op: SASL auth operation
2016-01-26 09:31:00.789 INFO net.spy.memcached.MemcachedConnection:  Reconnection due to exception handling a memcached operation on {QA sa=/xxx.xx.x.xxx:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=1}. This may be due to an authentication failure.
OperationException: SERVER: Auth failure
at net.spy.memcached.protocol.BaseOperationImpl.handleError(BaseOperationImpl.java:192)
at net.spy.memcached.protocol.binary.OperationImpl.finishedPayload(OperationImpl.java:204)
at net.spy.memcached.protocol.binary.SASLBaseOperationImpl.finishedPayload(SASLBaseOperationImpl.java:98)
at net.spy.memcached.protocol.binary.OperationImpl.readPayloadFromBuffer(OperationImpl.java:196)
at net.spy.memcached.protocol.binary.OperationImpl.readFromBuffer(OperationImpl.java:139)
at net.spy.memcached.MemcachedConnection.readBufferAndLogMetrics(MemcachedConnection.java:861)
at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:840)
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)
2016-01-26 09:31:00.791 WARN net.spy.memcached.MemcachedConnection:  Closing, and reopening {QA sa=/xxx.xx.x.xxx:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=1}, attempt 0.
2016-01-26 09:31:00.794 ERROR net.spy.memcached.protocol.binary.SASLAuthOperationImpl:  Error:  Auth failure
2016-01-26 09:31:00.794 WARN net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl:  Discarding partially completed op: SASL auth operation
2016-01-26 09:31:00.795 INFO net.spy.memcached.MemcachedConnection:  Reconnection due to exception handling a memcached operation on {QA sa=/xxx.xx.x.xxx:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=1}. This may be due to an authentication failure.
OperationException: SERVER: Auth failure
at net.spy.memcached.protocol.BaseOperationImpl.handleError(BaseOperationImpl.java:192)
at net.spy.memcached.protocol.binary.OperationImpl.finishedPayload(OperationImpl.java:204)
at net.spy.memcached.protocol.binary.SASLBaseOperationImpl.finishedPayload(SASLBaseOperationImpl.java:98)
at net.spy.memcached.protocol.binary.OperationImpl.readPayloadFromBuffer(OperationImpl.java:196)
at net.spy.memcached.protocol.binary.OperationImpl.readFromBuffer(OperationImpl.java:139)
at net.spy.memcached.MemcachedConnection.readBufferAndLogMetrics(MemcachedConnection.java:861)
at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:840)
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)
2016-01-26 09:31:00.796 WARN net.spy.memcached.MemcachedConnection:  Closing, and reopening {QA sa=/xxx.xx.x.xxx:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=1}, attempt 0.
2016-01-26 09:31:00.891 WARN net.spy.memcached.auth.AuthThread:  Authentication failed to /xxx.xx.x.xxx:11211, Status: {OperationStatus success=false:  cancelled}
2016-01-26 09:31:00.899 WARN net.spy.memcached.auth.AuthThread:  Authentication failed to /xxx.xx.x.xxx:11211, Status: {OperationStatus success=false:  cancelled}

Calvin Chen

unread,
Jan 26, 2016, 4:48:53 PM1/26/16
to Couchbase
Figured out the issue was with my xml configuration, the authDescriptor argument encapsulation was off.

<property name="configuration">

    <bean class="com.google.code.ssm.providers.spymemcached.SpymemcachedConfiguration">

        <property name="useBinaryProtocol" value="true" />

        <property name="consistentHashing" value="true" />

        <property name="failureMode" value="Redistribute"/>

        <property name="hashAlg">

<value type="net.spy.memcached.DefaultHashAlgorithm">KETAMA_HASH</value>

</property>

    <property name="authDescriptor">

        <bean class="net.spy.memcached.auth.AuthDescriptor">

            <constructor-arg index="0">

                <value>PLAIN</value>

            </constructor-arg>

            <constructor-arg index="1">

                <bean class="net.spy.memcached.auth.PlainCallbackHandler">

                    <constructor-arg index="0" value="blah"/>

                    <constructor-arg index="1" value="blah"/>

                </bean>

            </constructor-arg>

        </bean>

        </property>

Reply all
Reply to author
Forward
0 new messages