0

I am running a Spring boot application that uses Spring data to connect to a remote instance of Couchbase on AWS.

My Couchbase configuration class looks like this:

@Value(value = "${couchbase-url}")
private String couchBaseUrl;

@Value("${couchbase-bucket}")
private String couchbaseBucketName;

@Value("${couchbase-password}")
private String couchbasePassword;

@Override
protected List<String> getBootstrapHosts() {
    return Arrays.asList(couchBaseUrl);
}

@Override
protected String getBucketName() {
    return couchbaseBucketName;
}

@Override
protected String getBucketPassword() {
    return couchbasePassword;
}

where my param values look something like this:

couchbase-url=34.168.163.36:8091

couchbase-bucket=conversion-data

couchbase-password=secretpassword

When running this against a local instance, everything works as expected. When I run against the remote instance I get the following errors:

com.couchbase.client.deps.io.netty.channel.ConnectTimeoutException: connection timed out: /10.0.10.140:8093

Where 10.0.10.140 is the private IP address. So the initial connection seems to be fine but after that it has my service redirecting to the private IP address.

Can anyone explain how I can get Couchbase to respond with the public IP address?

DavidR
  • 6,622
  • 13
  • 56
  • 70
  • In the error log the port number is `8093` but in configuration file the port number is `8091`, this is misleading to think about the problem. Can you provide more info regarding this? – Vineeth Guna Jan 04 '18 at 02:29
  • `connection timed out` can even occur if the client is not able to communicate with the server, so use `telnet` to check whether you are able to communicate to couchbase, if not the issue can be in security groups or network ACL(if you are in vpc) – Vineeth Guna Jan 04 '18 at 02:31
  • @VineethGuna - Port 8091 is the original connection to Couchbase and that works fine. However, the application also needs to make various other calls to Couchbase which happens on different ports. It is during that original call that it gets the servers private IP address (I never supply it with that info). It then tries to make subsequent calls on the other ports with the private IP instead of the public IP I originally supplied. – DavidR Jan 04 '18 at 04:09

1 Answers1

1

While adding a server to a couchbase cluster it asks for the ip address or the hostname of the server, just enter the public ip of the server

The ip address which you have used to configure the server in the cluster is what couchbase returns to the client for any operation(like adding a key value)

References

But as a general practice communicating via public ip is not recommended

If you are using AWS, you can deploy the couchbase cluster in a dedicated VPC and deploy you spring application in another VPC. Then you can use VPC Peering to establish an internal network connection between these two VPC's.

Once the above setup is up and running you can use private ip to communicate to the servers in the couchbase cluster

Vineeth Guna
  • 388
  • 4
  • 10