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

Couchbase Server 1.8 connection issue with PHP

4 replies [Last post]
  • Login or register to post comments
Thu, 02/02/2012 - 00:27
sijisahadevan
Offline
Joined: 01/23/2012
Groups: None

Hi,

I am using Couchbase Server 1.8 community edition in 3 nodes. The auto fail over functionality is working properly when a server fails, But PHP client could not connect to the rest of the server nodes.

I am connecting to the cluster by using the following method

$cb_obj = new Couchbase("localhost", "Administrator", "password", "default");

Error shown when one of the node fails(localhost)

Warning: Couchbase::__construct(): Failed to connect libcouchbase to server: Network error in......

Please help.

Regards,
Siji

Top
  • Login or register to post comments
Wed, 02/08/2012 - 07:31
jan
Offline
Joined: 02/15/2011
Groups: None

Hi Siji,

thanks for the report, I'm looking into this today :)

Cheers
Jan
--

Top
  • Login or register to post comments
Wed, 02/08/2012 - 09:15
jan
Offline
Joined: 02/15/2011
Groups: None

Hi again Siji,

do I guess correctly that your scenario is the following:

1. Set up a cluster on localhost and one or more other hosts.
2. Use new Couchbase("localhost", ...);
3. Make the localhost node fail.
4. new Couchbase("localhost, ...); fails.

If that is correct, we are working on a fix that allows you to specify multiple hosts at once in your PHP script. Really, we should have done so all along, but we only now got to it.

In the meantime you could do this:

<?php
// excuse any errors, I haven't run this, I'm just illustrating ;)
$hosts = array("localhost", "otherhost", "yetanotherhost");
foreach($hosts AS $host) {
$cb = @new Couchbase($host, ...);
if($cb) {
break;
}
}

if(!$cb) {
// throw error, no server available
}

Cheers
Jan
--

Top
  • Login or register to post comments
Wed, 02/08/2012 - 21:49
sijisahadevan
Offline
Joined: 01/23/2012
Groups: None

Hi Jan,

Thanks for your replay, Your guessing was correct, That was the exact problem we were facing. we already implemented one similar method and it seems working fine now.

We are looking out for the proper fix.

Regards,
Siji

Top
  • Login or register to post comments
Thu, 02/09/2012 - 08:24
avsej
avsej's picture
Offline
Joined: 06/15/2011
Groups: None

Hi Siji

Next version of libcouchbase (and also all clients using it underneath) will have a patch which allows connection to use list of last known nodes from the cluster. This means that if your _initial_ connection was successful, you can be sure that, when the current node will fail, the connection will be still alive while at least one node in cluster is alive. There is an API (for upcoming version) to get current host and port https://github.com/couchbase/libcouchbase/blob/master/include/libcouchba... so Jan could expose it to php land.

So with next version code snippet will be totally valid (unlike with current, where the initial node still might fail later)

__________________

Find me on FreeNode IRC in #libcouchbase channel

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