Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

LibCouchbase on Windows: Hostname not working

5 replies [Last post]
  • Login or register to post comments
Fri, 07/06/2012 - 02:17
DonCa
Offline
Joined: 07/06/2012
Groups: None

I am using the current libcouchbase version from github.

The following code is used to connect to a Couchbase cluster:

libcouchbase_t instance;    /* our libcouchbase instance */
libcouchbase_error_t oprc;  /* for checking various responses */
 
const char *host = "127.0.0.1:8091";
const char *username = "bucket";
const char *passwd = "secret";
const char *bucket = "bucket";
 
instance = libcouchbase_create(host, username,
                               passwd, bucket, NULL);
if (instance == NULL) {
    fprintf(stderr, "Failed to create libcouchbase instance\n");
    return 1;
}
 
(void)libcouchbase_set_error_callback(instance, error_callback);
(void)libcouchbase_set_get_callback(instance, get_callback);
 
if (libcouchbase_connect(instance) != LIBCOUCHBASE_SUCCESS) {
    fprintf(stderr, "Failed to connect libcouchbase instance to server\n");
    return 1;
}
 
/* Wait for the connect to compelete */
libcouchbase_wait(instance);

This code works fine. But if I change the host to "localhost:8091", libcouchbase_wait calls the error_callback with the code LIBCOUCHBASE_CONNECT_ERROR.

It seems that libcouchbase cannot resolve the name "localhost" to the IP 127.0.0.1. The same error occurs when I the computername as host. Using the external IP will work again.

TL;DR: IP adresses as host are working, hostnames do not work

How do I use hostnames correctly with libcouchbase?

Greetings
DonCa

Top
  • Login or register to post comments
Tue, 08/07/2012 - 10:42
ingenthr
Offline
Joined: 03/16/2010
Groups:

Does 'localhost' look up correctly in other applications? Does libcouchbase work with other hostname lookups? I do remember that Windows Vista had an issue where localhost would end up going to DNS lookup-- I don't know if that has been resolved or which version of Windows you're using.

For example:
http://yacoding.blogspot.com/2008/07/localhost-redirecting-to.html

We can certainly look at this, but it would be good to rule out lookup issues first.

Top
  • Login or register to post comments
Wed, 08/08/2012 - 00:05
DonCa
Offline
Joined: 07/06/2012
Groups: None

"localhost" looks up correctly (as "::1" IPv6 adress). Other hostnames are not working with libcouchbase (they are also looked up as IPv6 adresses).

I am using Windows 7 64-bit with IPv6 enabled. Therefore "localhost" resolves to "::1" (IPv6 address). To me it seems that LibCouchbase may have a problem with IPv6 adresses using a Windows OS. I altered the LibCouchbase code, so that it would lookup only IPv4 adresses and everything works just fine.

You may consider including a Windows IPv6 enabled systems in your test scenarios.

Top
  • Login or register to post comments
Wed, 08/22/2012 - 00:17
ingenthr
Offline
Joined: 03/16/2010
Groups:

Yes, we'll definitely want to do this. Sorry for the trouble.

Top
  • Login or register to post comments
Wed, 08/22/2012 - 00:34
ingenthr
Offline
Joined: 03/16/2010
Groups:

You can track this issue here: http://www.couchbase.com/issues/browse/CCBC-93

Thanks for letting us know. If you have any thoughts on where the issue is, please let us know.

Top
  • Login or register to post comments
Wed, 08/22/2012 - 01:30
trond
trond's picture
Offline
Joined: 03/15/2010
Groups: None

Have you verified that you have a server listening on IPv6 on localhost?

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