Justin Borromeo
Justin Borromeo

Reputation: 1341

Cassandra - Which IP address do you use to connect to a cluster when using a driver?

I have deployed a 3-node Cassandra cluster on AWS (EC2). I'm trying to connect to the cluster from a .NET console application running on my computer. The Datastax website provides the following code sample for connecting to a local instance:

Cluster cluster = Cluster.Builder().AddContactPoint("127.0.0.1").Build();

I've set cassandra.yaml such that nodetool status displays the node's address as the EC2 instance's private IP address. However, if I use the private address in the AddContactPoint() function, the .NET driver returns an error saying that none of the hosts tried for query are available.

enter image description here

Which IP address do you use (instead of 127.0.0.1) in the AddContactPoint() function for connecting to the Cassandra cluster in AWS? The EC2 instance's public or private IP address? Or something else?

My settings in cassandra.yaml are:

rpc_address: 0.0.0.0
broadcast_rpc_address: *EC2's public IP address*
listen_address: *EC2's private IP address*

Thanks in advance.

Upvotes: 1

Views: 1834

Answers (2)

Vincent Khedkar
Vincent Khedkar

Reputation: 96

For the broadcast_rpc_address you would use the EC2's Public IP address as that's the address at which all your clients be connecting. listen_address is used for internode communication between nodes in the cluster.

Upvotes: 1

Christopher Bradford
Christopher Bradford

Reputation: 2260

Check out the rpc_address and more specifically for your environment the broadcast_rpc_adddress. The broadcast_rpc_address should be your public ip. Additionally look at the listen_address docs which discuss appropriate values to set in an EC2 e

Upvotes: 2

Related Questions