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

Problems with getting .NET Sample working with Membase on Mac OS X, on Windows it works fine...

1 reply [Last post]
  • Login or register to post comments
Thu, 08/11/2011 - 10:59
lu4
Offline
Joined: 08/11/2011
Groups: None

 Hi, I've been struggling for over 24 hours already while trying to get the example .NET client application to communicate with Membase on Mac OS X Lion. I think it might be bug because the code works perfectly on windows

using System;

using System.Collections.Generic;

using System.Text;

using Enyim.Caching;

using Enyim.Caching.Memcached;

using System.Net;

using Enyim.Caching.Configuration;

using Membase;

using Membase.Configuration;

using System.Threading;

 

namespace DemoApp

{

class Program

{

static void Main(string[] args)

{

            var config = new MembaseClientConfiguration();

            

            config.Urls.Add(new Uri("http://localhost:8091/pools/default"));

 

            var mc = new MembaseClient(config, "default", "");

 

// create a MemcachedClient

// in your application you can cache the client in a static variable or just recreate it every time

// MemcachedClient mc = new MemcachedClient();

 

// you can create another client using a different section from your app/web.config

// this client instance can have different pool settings, key transformer, etc.

// MemcachedClient mc2 = new MemcachedClient("memcached");

 

// or just initialize the client from code

 

            //MemcachedClientConfiguration config = new MemcachedClientConfiguration();

            //config.Servers.Add(new IPEndPoint(IPAddress.Loopback, 11211));

            //config.Protocol = MemcachedProtocol.Binary;

            //config.Authentication.Type = typeof(PlainTextAuthenticator);

            //config.Authentication.Parameters["userName"] = "demo";

            //config.Authentication.Parameters["password"] = "demo";

 

            //var mc = new MemcachedClient(config);

 

for (var i = 0; i < 100; i++)

mc.Store(StoreMode.Set, "Hello", "World");

 

            var value = mc.Get<String>("Hello");

 

            Console.WriteLine(value);

 

// simple multiget; please note that only 1.2.4 supports it (windows version is at 1.2.1)

//List<string> keys = new List<string>();

 

//for (int i = 1; i < 100; i++)

//{

//    string k = "aaaa" + i + "--" + (i * 2);

//    keys.Add(k);

 

//    mc.Store(StoreMode.Set, k, i);

//}

 

//IDictionary<string, ulong> cas;

//IDictionary<string, object> retvals = mc.Get(keys, out cas);

 

//List<string> keys2 = new List<string>(keys);

//keys2.RemoveRange(0, 50);

 

//IDictionary<string, object> retvals2 = mc.Get(keys2, out cas);

//retvals2 = mc.Get(keys2, out cas);

 

//ServerStats ms = mc.Stats();

 

// store a string in the cache

//mc.Store(StoreMode.Set, "MyKey", "Hello World");

 

// retrieve the item from the cache

//Console.WriteLine(mc.Get("MyKey"));

 

//Console.WriteLine(mc.Increment("num1", 1, 10));

//Console.WriteLine(mc.Increment("num1", 1, 10));

//Console.WriteLine(mc.Decrement("num1", 1, 14));

 

//// store some other items

//mc.Store(StoreMode.Set, "D1", 1234L);

//mc.Store(StoreMode.Set, "D2", DateTime.Now);

//mc.Store(StoreMode.Set, "D3", true);

//mc.Store(StoreMode.Set, "D4", new Product());

 

//mc.Store(StoreMode.Set, "D5", new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

 

 

////mc2.Store(StoreMode.Set, "D1", 1234L);

////mc2.Store(StoreMode.Set, "D2", DateTime.Now);

////mc2.Store(StoreMode.Set, "D3", true);

////mc2.Store(StoreMode.Set, "D4", new Product());

 

//Console.WriteLine("D1: {0}", mc.Get("D1"));

//Console.WriteLine("D2: {0}", mc.Get("D2"));

//Console.WriteLine("D3: {0}", mc.Get("D3"));

//Console.WriteLine("D4: {0}", mc.Get("D4"));

 

//byte[] tmp = mc.Get<byte[]>("D5");

 

//// delete them from the cache

//mc.Remove("D1");

//mc.Remove("D2");

//mc.Remove("D3");

//mc.Remove("D4");

 

//ServerStats stats = mc.Stats();

//Console.WriteLine(stats.GetValue(ServerStats.All, StatItem.ConnectionCount));

//Console.WriteLine(stats.GetValue(ServerStats.All, StatItem.GetCount));

 

//// add an item which is valid for 10 mins

//mc.Store(StoreMode.Set, "D4", new Product(), new TimeSpan(0, 10, 0));

 

Console.ReadLine();

}

 

// objects must be serializable to be able to store them in the cache

[Serializable]

class Product

{

public double Price = 1.24;

public string Name = "Mineral Water";

 

public override string ToString()

{

return String.Format("Product {{{0}: {1}}}", this.Name, this.Price);

}

}

}

}

 

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

First off, do note that we had a minor bug with MacOS Lion, but that was addressed in Membase 1.7.1. I don't think that bug would have affected this case though.

Chances are, the issues are related to network connectivity. We verified the sample under similar circumstances, and it seems to be working fine.

Is there any possibility that the Windows client can't get to the Membase server? This could be either on the MacOS side or the Windows firewall blocking outgoing traffic to unknown ports. TCP ports 8091, 11211 and 11210 need to be open from the client to the server.

Also, are your systems running on virtual machines? If, for instance, windows is in a virtual machine running locally on MacOS, you may need to use a different IP address or set up the virtual networking differently.

We'd be glad to help further with some other information.

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