Mahesh Bansode
Mahesh Bansode

Reputation: 297

Exception while connecting Couchbase server using .net connectors

I am getting exception while connecting couchbase cluster (server) using .Net SDK, using latest .net connectors for Couchbase server. Attaching C# code and App.config.

Exception:

"An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll Additional information: Unrecognized attribute 'OperationLifeSpan'. Note that attribute names are case-sensitive."

Please help me if I am missing something here,

C# Code:

public static void CreateOrder()
{
    using (var cluster = new Cluster("couchbaseClients/couchbase"))
    {
        IBucket bucket = null;

        try
        {
            bucket = cluster.OpenBucket();

            var order = new Document<Order>()
            {
                Id = Guid.NewGuid().ToString(),
                Content = new Order()
                {
                    Name="Tiffin",
                    Location="WITP",
                    Quantity=2
                }
            };

            var result = bucket.Insert(order);

            if (result.Success)
                Console.WriteLine("Order Created '{0}'", order.Id);
        }
        finally
        {
            if (bucket != null)
                cluster.CloseBucket(bucket);
        }
    }
}

Config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="couchbaseClients">
      <section name="couchbase"
               type="Couchbase.Configuration.Client.Providers.CouchbaseClientSection, Couchbase.NetClient"/>
    </sectionGroup>
  </configSections>
  <couchbaseClients>
    <couchbase useSsl="false" operationLifeSpan="1000">
      <servers>
        <add uri="http://192.168.56.101:8091/pools"></add>
        <add uri="http://192.168.56.102:8091/pools"></add>
        <add uri="http://192.168.56.103:8091/pools"></add>
        <add uri="http://192.168.56.104:8091/pools"></add>
      </servers>
      <buckets>
        <add name="default" useSsl="false" password="" operationLifespan="2000">
          <connectionPool name="custom" maxSize="10" minSize="5" sendTimeout="12000"></connectionPool>
        </add>
      </buckets>
    </couchbase>
  </couchbaseClients>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
  </startup>
</configuration>

Upvotes: 1

Views: 301

Answers (1)

Roi Katz
Roi Katz

Reputation: 575

You have upprecase S instead of lowercase s in operationLifespan.

try

    <couchbase useSsl="false" operationLifespan="1000">

instead of

    <couchbase useSsl="false" operationLifeSpan="1000">

Upvotes: 1

Related Questions