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

couchbase server "http://Server:8091/pools/default" internal server error

5 replies [Last post]
  • Login or register to post comments
Tue, 07/10/2012 - 10:22
Hendra
Offline
Joined: 04/29/2012
Groups: None

Hi there,

i used couchbase for sometimes now. lately i received an error mention below :

" ERROR2012-07-10 23:12:09 – [4] - HB: Node 'http://testserver02:8091/pools/default' is not available.
System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.GetResponse()
at Couchbase.MessageStreamListener.Heartbeat.Worker(Object state) "

i have no idea what cause this error. need enlightenment please.

thanks

Top
  • Login or register to post comments
Tue, 07/10/2012 - 18:18
mikew
Offline
Joined: 03/14/2011
Groups:

Can you post the code that generated this error?

Top
  • Login or register to post comments
Wed, 07/11/2012 - 01:08
Hendra
Offline
Joined: 04/29/2012
Groups: None

Hello Mikew,

The problem is i don't know which code cause this error. the error happen intermittently. no idea when or where this error occurred.

btw what can cause this error ?

here is my caching code, hope this can help find the source of the problem (this is C# code):

----------------------------------
Cache Client Factory
----------------------------------

    public interface ICacheClient
    {
        object Get(string cacheKey);
        bool Store(string cacheKey, object value);
        bool Store(string cacheKey, object value, TimeSpan lifeTime);
    }
 
    public class CouchbaseServerCacheClient : ICacheClient
    {
        CouchbaseClient cc = null;
 
        public CouchbaseServerCacheClient(string bucketName, string bucketPassword, Uri serverUrl)
        {
            cc = CouchbaseClientFactory.getClient(bucketName, bucketPassword, serverUrl);
 
        }
 
        public object Get(string cacheKey)
        {
            return cc.Get(cacheKey);
        }
 
        public bool Store(string cacheKey, object value)
        {
            return cc.Store(StoreMode.Set, cacheKey, value);
        }
 
        public bool Store(string cacheKey, object value, TimeSpan lifeTime)
        {
            return cc.Store(StoreMode.Set, cacheKey, value, lifeTime);
        }
    }
 
    class CouchbaseClientFactory
    {
        private static Dictionary<string, CouchbaseClient> ListCouchbaseClient = new Dictionary<string, CouchbaseClient>();
        private static readonly object _locker = new object();
 
        public static CouchbaseClient getClient(string _bucketName, string _bucketPassword, Uri _serverUrl)
        {
            CouchbaseClient result;
 
            lock (_locker)
            {
                if (ListCouchbaseClient.ContainsKey(_bucketName))
                {
                    result = ListCouchbaseClient[_bucketName];
                }
                else
                {
                    CouchbaseClient c = createClient(_bucketName, _bucketPassword, _serverUrl);
                    if (c != null)
                    {
                        ListCouchbaseClient.Add(_bucketName, c);
                    }
                    else
                    {
                        Logger.LogManager.LogError("Failed to create Couchbase Client");
                    }
 
                    result = c;
                }
            }
            return result;
        }
 
        private static CouchbaseClient createClient(string name, string password, Uri serverUrl)
        {
            CouchbaseClientConfiguration config = new CouchbaseClientConfiguration();
            config.Urls.Add(serverUrl);
            config.Bucket = name;
            config.BucketPassword = password;
            config.SocketPool.ConnectionTimeout = new TimeSpan(0, 0, 20);
            config.SocketPool.DeadTimeout = new TimeSpan(0, 2, 0);
            config.SocketPool.MinPoolSize = 20;
            config.SocketPool.MaxPoolSize = 200;
            config.RetryCount = 0;
            config.RetryTimeout = new TimeSpan(0, 0, 2);
 
            CouchbaseClient c = new CouchbaseClient(config);
 
            return c;
        }
    }

----------------------
Caching Class
----------------------

    public abstract class ServerCacheBase
    {
        const string DEFAULT_BUCKET_NAME = "default";
        const string DEFAULT_BUCKET_PASSWORD = "";
 
        protected ICacheClient cacheClient;
 
        /// <summary>
        /// Cache item life time in milliseconds.
        /// </summary>
        public int ItemLifeTime { get; set; }
 
        /// <summary>
        /// The key to store the value in cache.
        /// </summary>
        public string CacheKey { get; set; }
 
        /// <summary>
        /// Bucket data name in membase
        /// </summary>
        public string BucketName { get; set; }
 
        /// <summary>
        /// Password for Bucket data in membase
        /// </summary>
        public string BucketPassword { get; set; }
 
        public bool IsUseCompression { get; set; }
 
        protected bool _isFromCache;
        public bool IsFromCache { get { return _isFromCache; } }
 
        public ServerCacheBase(string cacheKey)
        {
            CacheKey = cacheKey;
            ItemLifeTime = 0;
            BucketName = DEFAULT_BUCKET_NAME;
            BucketPassword = DEFAULT_BUCKET_PASSWORD;
 
            initCacheClient();
        }
 
        public ServerCacheBase(string cacheKey, string bucketName, string bucketPassword)
        {
            CacheKey = cacheKey;
            ItemLifeTime = 0;
            BucketName = bucketName;
            BucketPassword = bucketPassword;
 
            initCacheClient();
        }
 
        protected virtual void initCacheClient()
        {
		cacheClient = new CouchbaseServerCacheClient(BucketName, BucketPassword, new Uri("http://testserver02:8091/pools/default");
        }
 
        private void SaveCache(string cacheKey, object val)
        {
            if (ItemLifeTime <= 0)
            {
                cacheClient.Store(cacheKey, val);
            }
            else
            {
                cacheClient.Store(cacheKey, val, new TimeSpan(ItemLifeTime * 10000)); // 1 millisecond = 10000 ticks
            }
        }
 
        protected void addToCache(string cacheKey, object val)
        {
            if (IsUseCompression)
            {
                using (System.IO.MemoryStream compressedData = CompressData(val))
                {
                    SaveCache(cacheKey, compressedData);
                }
            }
            else
            {
                SaveCache(cacheKey, val);
            }
 
        }
 
        protected object getFromCache(string cacheKey)
        {
            object retVal;
            object cache_value = cacheClient.Get(cacheKey);
 
            if (IsUseCompression)
            {
                retVal = DecompressData(cache_value);
            }
            else
            {
                retVal = cache_value;
            }
 
            return retVal;
 
        }
    }
 
    public abstract class CommonServerCache<T> : ServerCacheBase
    {
        /// <summary>
        /// cache to "default" bucket
        /// </summary>
        /// <param name="cacheKey"></param>
        public CommonServerCache(string cacheKey)
            : base(cacheKey)
        {
        }
 
        /// <summary>
        /// Cache to specified "bucketName" Bucket
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <param name="bucketName"></param>
        /// <param name="bucketPassword"></param>
        public CommonServerCache(string cacheKey, string bucketName, string bucketPassword)
            : base(cacheKey, bucketName, bucketPassword)
        {
        }
 
        /// <summary>
        /// Retrieve value from cache if exist or from DB if it's not. Return null if no value exists in DB.
        /// </summary>
        /// <returns>Null or the instance of T</returns>
        public virtual T RetrieveValue()
        {
            T retVal = default(T);
            string key = CacheKey;
            object valFromCache = null;
            _isFromCache = false;
 
            while (true)
            {
                valFromCache = getFromCache(key);
 
                if (valFromCache == null)
                {
                    try
                    {
                        T valueFromDB = GetValueFromDB();
                        if (valueFromDB != null)
                        {
                            addToCache(key, valueFromDB);
                            retVal = valueFromDB;
                        }
 
                        _isFromCache = false;
                        //retrieve from DB
                    }
                    finally
                    {
                    }
 
                    break;
                }
                else
                {
                    retVal = (T)valFromCache;
                    _isFromCache = true;
                    break;
                }
            }
            return retVal;
        }
 
        /// <summary>
        /// Get the value from database.
        /// </summary>
        /// <returns>Null or the instance of T.</returns>
        public abstract T GetValueFromDB();
 
        public void UpdateCache(T updatedData)
        {
            string key = CacheKey;
 
            if (updatedData != null)
            {
                addToCache(key, updatedData);
            }
            else
            {
                LogManager.LogError("CommonMembaseCache UpdateCache error, Value to update is null.");
            }
        }
    }

Top
  • Login or register to post comments
Wed, 08/15/2012 - 06:57
kyleheon
kyleheon's picture
Offline
Joined: 06/26/2012
Groups: None

We are seeing this with Couchbase 2.0, build 1495 and have not found the cause or a solution. Has anyone found what is causing this and/or have a way to work around it?

Top
  • Login or register to post comments
Wed, 08/15/2012 - 09:48
john
Offline
Joined: 01/05/2012
Groups: None

I can't speak to why you're getting 500 errors, but you could try disabling or making the heartbeat beat less frequently - see the link below for more details.

http://www.couchbase.com/docs/couchbase-sdk-net-1.1/couchbase-sdk-net-co...

Top
  • Login or register to post comments
Wed, 08/15/2012 - 21:02
Hendra
Offline
Joined: 04/29/2012
Groups: None

john wrote:
I can't speak to why you're getting 500 errors, but you could try disabling or making the heartbeat beat less frequently - see the link below for more details.

http://www.couchbase.com/docs/couchbase-sdk-net-1.1/couchbase-sdk-net-configuration.html

ok. let me try this method. btw where can i find this setting in the .net client library ? i don't use webconfig setting to create my client :p.

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