Couchbase ServerUnavailableException


#1

I am getting an error with .Net 2.0.2 ( IsSecure = ‘_bucket.IsSecure’ threw an exception of type ‘Couchbase.ServerUnavailableException’) I have a the code below. using Autofac dependency injection. Any idea of what may be causing this issue?

public abstract class RepositoryBase where T : ModelBase
{
private readonly IBucket _bucket;

    protected RepositoryBase()
    {
        _bucket = CouchbaseDatabaseHelper.GetCouchbaseBucket(typeof(T).Name.ToLower());
    }

    public IBucket Bucket
    {
        get { return _bucket; }
    }

}

public static class CouchbaseDatabaseHelper
{
public static IBucket GetCouchbaseBucket(string type)
{
var bucketName = “user”;

        if (type == "session" || type == "cache")
        {
            bucketName = "session";
        }
        else if (type == "log")
        {
            bucketName = "Log";
        }

        ClusterHelper.Initialize("couchbaseClients/couchbase");
        var cluster = ClusterHelper.Get();
        var bucket = cluster.OpenBucket(bucketName);
        return bucket;
    }
}

#2

@3rdWorld -

I am not 100% sure but I am guessing that Autofac is calling IsSecure somehow before the bucket is actually initialized.

An easy bug fix will simply to catch the exception in IsSecure and return false. I created a jira ticket for a bug fix: https://issues.couchbase.com/browse/NCBC-817

If you enabled logging that might help to figure out what is going on.

-Jeff


#3

@jmorris here is the error from the log file. Still having the issue any ideas.
2015-03-20 12:49:29.7433 Couchbase.IO.ConnectionPool1[[Couchbase.IO.Connection, Couchbase.NetClient, Version=2.0.2.0, Culture=neutral, PublicKeyToken=05e9c6b5a9ec94c2]] Releasing: 6a1f8eb4-707b-4c50-9394-4aba69875c11 on 192.168.2.18:11210 - c47bbd71-a61b-498b-87a9-9f2c0c8b7a6a 2015-03-20 12:49:29.8293 Couchbase.CouchbaseBucket System.AggregateException: One or more errors occurred. ---> Couchbase.ServerUnavailableException: Exception of type 'Couchbase.ServerUnavailableException' was thrown. at Couchbase.Configuration.ConfigContextBase.GetServer() at Couchbase.CouchbaseBucket.<>c__DisplayClass641.b__62(ViewQuery e, IConfigInfo c)
at Couchbase.CouchbaseBucket.d__6a1.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait(CancellationToken cancellationToken) at Couchbase.CouchbaseBucket.SendWithRetry[T](ViewQuery query) ---> (Inner Exception #0) Couchbase.ServerUnavailableException: Exception of type 'Couchbase.ServerUnavailableException' was thrown. at Couchbase.Configuration.ConfigContextBase.GetServer() at Couchbase.CouchbaseBucket.<>c__DisplayClass641.b__62(ViewQuery e, IConfigInfo c)
at Couchbase.CouchbaseBucket.d__6a`1.MoveNext()<—


#4

@3rdWorld -

The stacktrace that you last posted indicates your executing a view request not an exception thrown by IsSecure; if i am wrong please explain. For the issue with IsSecure and autofac, we have a fix that is scheduled for 2.1.0: https://issues.couchbase.com/browse/NCBC-817

BTW, looking at your code above, the ClusterHelper.Initialize() method should only be called once, so if your doing it every time you request a bucket reference, that may cause problems. Note that if your using the ClusterHelper, you may also want to use ClusterHelper.GetBucket(bucketName), this will cache your bucket reference so that subsquent calls get the cached bucket reference. The GetBucket method was added in 2.0.2, so you may want to update to the latest.

Thanks,

Jeff


#5

when will 2.1.0 be released


#6

@3rdWorld

It’s planned for April 2015…depends upon how well testing goes, but could be first week but more likely later.

-Jeff


#7

@jmorris thank you very much