Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Membase | Membase Server 1.6.x

spymemcached client can not access the membase server

19 replies [Last post]
  • Login or register to post comments
Thu, 06/30/2011 - 03:24
jerome_tan
Offline
Joined: 06/30/2011
Groups: None

Hi,

I use spymemcached 2.7 version to access membase server 1.6.5.4 by the following code:

            URI base = new URI("http://localhost:8091/pools/");
            URI base1 = new URI("http://192.168.103.60:8091/pools");
            ArrayList<URI> baseURIs = new ArrayList<URI>();
            baseURIs.add(base);
            baseURIs.add(base1);
            System.out.println(baseURIs);
            mc = new MemcachedClient(baseURIs, "default", "");

And the client returns such exception:

Exception in thread "main" java.lang.NullPointerException
	at net.spy.memcached.vbucket.ConfigurationProviderHTTP.readToString(ConfigurationProviderHTTP.java:270)
	at net.spy.memcached.vbucket.ConfigurationProviderHTTP.readPools(ConfigurationProviderHTTP.java:104)
	at net.spy.memcached.vbucket.ConfigurationProviderHTTP.getBucketConfiguration(ConfigurationProviderHTTP.java:85)
	at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:223)
	at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:300)
	at Main.main(Main.java:32)

Line 32 is "mc = new MemcachedClient(baseURIs, "default", "");"

Top
  • Login or register to post comments
Thu, 06/30/2011 - 17:58
mikew
Offline
Joined: 03/14/2011
Groups:

The URI for the base1 variable looks to be invalid. You put the ip address 192.168.103.60 and I think you meant to put 192.168.103. If you still have issues let us know.

Top
  • Login or register to post comments
Thu, 06/30/2011 - 20:01
jerome_tan
Offline
Joined: 06/30/2011
Groups: None

I change the code to

            URI base = new URI("http://localhost:8091/pools/");
//            URI base1 = new URI("http://192.168.103.60:8091/pools");
            ArrayList<URI> baseURIs = new ArrayList<URI>();
            baseURIs.add(base);
//            baseURIs.add(base1);
            System.out.println(baseURIs);
            mc = new MemcachedClient(baseURIs, "default", "");

still to got the same exception.
Do you mean to put "192.168.103."? like URI base = new URI("http://192.168.103:8091/pools/");??

I visit http://localhost:8091/pools/ and the server returns:

{"pools":[{"name":"default","uri":"/pools/default","streamingUri":"/poolsStreaming/default"}],"isAdminCreds":false,"implementationVersion":"1.6.5.4","componentsVersion":{"os_mon":"2.2.4","mnesia":"4.4.12","inets":"5.2","kernel":"2.13.4","sasl":"2.1.8","ns_server":"1.6.5.4","menelaus":"1.6.5.4","stdlib":"1.16.4"}}

and I visit http://192.168.103.60:8091/pools/ it returns the same result.

Top
  • Login or register to post comments
Thu, 06/30/2011 - 20:51
mikew
Offline
Joined: 03/14/2011
Groups:

Sorry about my last comment. For some reason I thought you had 5 bytes in you ip address instead of 4 so I completely misread your code. You had everything right.

I recognize the issue here as one that we recently fixed. What is somewhat strange to me though is that the NullPointerException only happened in my testing when I tried connecting to a bucket that either didn't exist or the password for the bucket was incorrect. Here though is seems that you have the bucket setup correctly. We are planning on releasing the code in the next week or so. In the meantime you could download and build the latest source code from Github. It is located at https://github.com/dustin/java-memcached-client. Let me know if you still have any any issues after this.

Top
  • Login or register to post comments
Thu, 07/07/2011 - 14:21
pd
Offline
Joined: 07/07/2011
Groups: None

I'm getting the same issue with the default bucket. I tried the most recent code (as of 7/7/11) and all that did was uncover the IOException that happens before the NullPointerException, so it still doesn't work.

The IOException happens in ConfigurationProvider.readToString at the line

InputStream inStream = connection.getInputStream()

see the last comment at http://code.google.com/p/spymemcached/wiki/Examples for the same issue

The latest code just adds an if !null check to reader.close(); to prevent the NullPointerException there, which was itself triggered by the IOException

Top
  • Login or register to post comments
Thu, 07/07/2011 - 15:57
perry
Offline
Joined: 10/11/2010
Groups:

Just to confirm, you do have a default bucket configured on the Membase cluster?

__________________

Forum support is great for free but sometimes you need a guaranteed response time and dedicated resources for your questions or issues.
Consider purchasing enterprise-level support from Couchbase: http://www.couchbase.com/products-and-services/overview
Call or email "sales -at- couchbase-dot- com" today!

Top
  • Login or register to post comments
Fri, 07/08/2011 - 08:26
pd
Offline
Joined: 07/07/2011
Groups: None

Hi perry, yes I have only the default bucket, with access control set to "Standard port (TCP port 11211. ASCII protocol or Binary auth-less)"

Top
  • Login or register to post comments
Fri, 07/08/2011 - 10:36
mikew
Offline
Joined: 03/14/2011
Groups:

It appears that you seem to be doing everything correctly. I however have been unable to reproduce this issue so far, but would like to get a fix in for this for our upcomig release of Spymemcached. Below are a few things you can do to help me figure out what is going on here.

1. Provide as much detail as possible into exactly what you are doing. What version of Membase are you running against? What OS? What is your exact source code (If you are doing the same thing as jerome above then just say so). Also with the latest code are you getting a stack trace from Spymemcached upon failure or are you just not getting the correct behavior (ie is Membase failing gracefully)?

2. Provide a packet trace of you program running.

Top
  • Login or register to post comments
Fri, 07/08/2011 - 12:06
pd
Offline
Joined: 07/07/2011
Groups: None

Here are the relevant log entries, which show an error trying to get back the pools (this is using the spymemcached code as of 7/7/11).

WARN net.spy.memcached.vbucket.ConfigurationProviderHTTP:  Connection problems with URI <a href="http://plf-membase-qa-1:8091/pools" title="http://plf-membase-qa-1:8091/pools">http://plf-membase-qa-1:8091/pools</a> ...skipping
java.io.IOException: Server returned HTTP response code: 500 for URL: <a href="http://plf-membase-qa-1:8091/pools<br />
" title="http://plf-membase-qa-1:8091/pools<br />
">http://plf-membase-qa-1:8091/pools<br />
</a>	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
	at net.spy.memcached.vbucket.ConfigurationProviderHTTP.readToString(ConfigurationProviderHTTP.java:248)
	at net.spy.memcached.vbucket.ConfigurationProviderHTTP.readPools(ConfigurationProviderHTTP.java:103)
	at net.spy.memcached.vbucket.ConfigurationProviderHTTP.getBucketConfiguration(ConfigurationProviderHTTP.java:84)
	at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:255)
	at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:216)
	at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:340)
 
net.spy.memcached.vbucket.ConfigurationException: Configuration for bucket default was not found.
	at net.spy.memcached.vbucket.ConfigurationProviderHTTP.readPools(ConfigurationProviderHTTP.java:148)
	at net.spy.memcached.vbucket.ConfigurationProviderHTTP.getBucketConfiguration(ConfigurationProviderHTTP.java:84)
	at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:255)
	at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:216)
	at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:340)

Going to http://plf-membase-qa-1:8091/pools manually I get a successful 200 response with

{"pools":[{"name":"default","uri":"/pools/default","streamingUri":"/poolsStreaming/default"}],"isAdminCreds":false,"uuid":"241251c3-f2a6-4001-15e8-856000000396","implementationVersion":"1.7.0","componentsVersion":{"kernel":"2.14.3","mnesia":"4.4.17","stdlib":"1.17.3","os_mon":"2.2.5","ns_server":"1.7.0","sasl":"2.1.9.3"}}

I looked at the request packet being sent, and saw that an Authorization: Basic header is being added. I tried adding the same header to a manual request, and got back a 500 response from the server as seen in the error log.

I'm using the same constructor as Jerome: mc = new MemcachedClient(baseURIs, "default", "");

The server is Membase Server 1.7.0 running on x86_64 CentOS release 5.5 (Final)

Top
  • Login or register to post comments
Fri, 07/08/2011 - 12:46
perry
Offline
Joined: 10/11/2010
Groups:

A 500 error should show up in the Membase logs as well...can you take a look at the "logs" link in the UI and see if there are any corresponding messages?

__________________

Forum support is great for free but sometimes you need a guaranteed response time and dedicated resources for your questions or issues.
Consider purchasing enterprise-level support from Couchbase: http://www.couchbase.com/products-and-services/overview
Call or email "sales -at- couchbase-dot- com" today!

Top
  • Login or register to post comments
Fri, 07/08/2011 - 12:51
ingenthr
Offline
Joined: 03/16/2010
Groups:

Hi,

There's a known issue in the current spymemcached with base64 encoding of authentication parameters. We're fixing that shortly.

A workaround for now is to change what you're using for the password for the bucket and ensure there aren't any complex characters. The other critical thing to do is make sure you use commons codec 1.4, since Apache had changed some things between 1.3 and 1.4, and then they changed them back in 1.5.

We'll likely update to something more recent in the next patch release, which should be out soon.

Regards,

Matt

Top
  • Login or register to post comments
Fri, 07/08/2011 - 12:58
pd
Offline
Joined: 07/07/2011
Groups: None

Yes this error is showing up:

Server error during processing: ["web request failed",
{path,"/pools"},
{type,error},
{what,function_clause},
{trace,
[{base64,decode,
["GZ",[86,102,23,86,199,67]]},
{menelaus_auth,extract_auth,1},
{menelaus_auth,apply_auth_bucket,3},
{menelaus_web,loop,3},
{mochiweb_http,headers,5},
{proc_lib,init_p_do_apply,3}]}]

Top
  • Login or register to post comments
Fri, 07/08/2011 - 13:04
ingenthr
Offline
Joined: 03/16/2010
Groups:

Can you try the workaround of using a simple password and ensuring that you're using the specific version of commons codec referenced?

Thanks.

Top
  • Login or register to post comments
Fri, 07/08/2011 - 13:26
pd
Offline
Joined: 07/07/2011
Groups: None

Hi Matt,

I checked the build file for spymemcached and it is specifying commons codec 1.4.

It looks like you're right about this being a base 64 encoding issue. I actually don't have a password set for the bucket. The request is passing "Authorization: Basic ZGVmYXVsdD", which looks like it might be a truncated encoding of "default:" ( encoding ZGVmYXVsdDo= ). When I did a manual request replacing ZGVmYXVsdD with ZGVmYXVsdDo= I got a successful 200 response.

Top
  • Login or register to post comments
Fri, 07/08/2011 - 13:29
pd
Offline
Joined: 07/07/2011
Groups: None

ingenthr wrote:
Can you try the workaround of using a simple password and ensuring that you're using the specific version of commons codec referenced?

Thanks.

Matt the membase admin doesn't let me set a password for the default bucket.

Top
  • Login or register to post comments
Fri, 07/08/2011 - 13:50
ingenthr
Offline
Joined: 03/16/2010
Groups:

This is pointing to the commons codec issue. Specifically, when I wrote this there was a \r\n I had to strip off, which was then changed in commons codec. If you upgrade/dowgrade specifically to Apache commons-codec 1.4, it'll strip the right characters off.

Sorry for the hassle. It turned out to be a bug in the upstream quite a while ago, and we'll have it fixed to handle either soon.

Top
  • Login or register to post comments
Fri, 07/08/2011 - 14:13
pd
Offline
Joined: 07/07/2011
Groups: None

ingenthr wrote:
This is pointing to the commons codec issue. Specifically, when I wrote this there was a \r\n I had to strip off, which was then changed in commons codec. If you upgrade/dowgrade specifically to Apache commons-codec 1.4, it'll strip the right characters off.

Sorry for the hassle. It turned out to be a bug in the upstream quite a while ago, and we'll have it fixed to handle either soon.

Awesome, you were right. The app was using commons-codec 1.5, and when I downgraded to 1.4 spymemcached started working. Thanks!

Top
  • Login or register to post comments
Mon, 10/10/2011 - 10:05
abhihome
Offline
Joined: 03/14/2011
Groups: None

Can I use

URI base = new URI("http://localhost:11211/pools/");
instead of
URI base = new URI("http://localhost:8091/pools/");

and start moxi to talk to the cluster?

So that I need not create multiple base urls, each time I add a new server.

When I tried, it just hung for ever waiting for the connection. Any idea?

Thanks
Abhilash

Top
  • Login or register to post comments
Mon, 10/10/2011 - 10:26
mikew
Offline
Joined: 03/14/2011
Groups:

1. You only need one URI and Spymemcached will be able to get the addresses from all of the servers. This is because Spymemcached can get the configuration of the entire cluster from a single server. So with this setup, if you add a node later spymemcached will receive an updated configuration from the cluster and immediately recognize the new node. The reason you would want to specify more than one URI is so that if the server you are getting the configuration from goes down then you will be able to get the configuration from another server in the cluster.

2.

URI base = new URI("http://localhost:11211/pools/");

This will not work. If you want to connect to moxi then you will want to use the constructor that takes a list of InetSocketAddress's. I don't recommend doing this though because it will add latency to all of your requests since most of them will have to take two hops to get to the correct server.

3. It wasn't clear how you set up you connection to Membase that caused it to hang. If you provide more detail as to what you did I will help find the issue.

Top
  • Login or register to post comments
Mon, 10/10/2011 - 10:50
abhihome
Offline
Joined: 03/14/2011
Groups: None

Thanks Mike for the detailed explanation.
Please don't mind point#3, as I didn't do it right as you have explained in point #2.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker