DavidR
DavidR

Reputation: 6962

Connecting to remote Couchbase instance on AWS using Spring data returns private IP address

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?

Upvotes: 0

Views: 789

Answers (1)

Vineeth Guna
Vineeth Guna

Reputation: 398

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

Upvotes: 1

Related Questions