Cannot boot strap using remote (not local) instance of CouchBase


#1

When running an instance of a WEB API project that is not local to the CouchBase sever I get the following error:

{“No connection could be made because the target machine actively refused it 127.0.0.1:11210”}

I would expect that the IP address of the server that CouchBase is running on would be returned, this is causing the Web API to talk to its local system.

I am using the following web.config:

 >  <configSections>
>     <sectionGroup name="couchbase">
>       <section name="bucket" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase" />
>     </sectionGroup>
>   </configSections>
>   <couchbase>
>     <bucket>
>       <servers bucket="tinman">
>         <add uri="http://10.82.120.12:8091/pools" />
>       </servers>
>     </bucket>
>   </couchbase>

And in the global.asa I have:

private static Cluster Cluster { get; set; }
public static IBucket Bucket;

    protected void Application_Start()
    {
        Cluster = new Cluster();
        Bucket = Cluster.OpenBucket("tinman");
       GlobalConfiguration.Configure(WebApiConfig.Register);
    }

    protected void Application_End()
    {
        if (Bucket != null)
        {
            Bucket.Dispose();
        }
        if (Cluster != null)
        {
            Cluster.Dispose();
        }
    }

I install the CouchBase server using the IP of the host (10.82.120.12) instead of 127.0.0.1

When running the same Web API project locally on the CouchBase server the application works as expected. For some reason the proxy details are being passed as localhost.


#2

@lakebrat

In Application_Start, you are using the default ctor which will use the default configuration (localhost). You just need to change:

Cluster = new Cluster();

To:

Cluster = new Cluster("couchbaseClients/couchbase");

And then update your configuration file to look like this:

<?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>
    <servers>
        <add uri="http://10.82.120.12:8091/pools"></add>
    </servers>
    <buckets>
        <add name="tinman"></add>
    </buckets>
    </couchbase>
</couchbaseClients>

Now it should work!

-Jeff