After few self tests, I thought I'm having a telnet
problem. So I am recreating a shorter version of this question
I have two machines:
- cassandra is running on one machine using IP 172.17.1.XX.
- ???
My java program is:
public static void main(String a[])
{
System.out.println("I am in");
Client client = new Client();
client.connect("172.17.1.XX");
client.close();
}
public static void connect(String node)
{
cluster = Cluster.builder().addContactPoint(node).withPort(9160).build();
Metadata metadata = cluster.getMetadata();
}
If I run this program in the cassandra machine, it works. If I run the same program from my second machine, the output is:
Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException:
All host(s) tried for query failed (tried: /172.17.1.XX:9160 (com.datastax.driver.core.TransportException: [/172.17.1.XX:9160] Cannot connect))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:196)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:80)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1145)
at com.datastax.driver.core.Cluster.getMetadata(Cluster.java:313)
at com.example.cassandra.Client.connect(Client.java:18)
at com.example.cassandra.Client.main(Client.java:74)
Using netstat -plten
on the cassandra machine returns
`9160 port is open for all. 0.0.0.0:9160`
If I use: telnet 172.17.1.XX 9160
???on what machine??? and type something and hit enter, the output is:
Connection closed by foreign agent
I tried the same telnet in the cassandra system with ip and localhost, i am getting the same behaviour.
telnet localhost 9160
accepts 3 inputs and says connection closed by foreign agent
whereas ip accepts only two inputs. What is it?
I have three questions:
- Why am I getting this error?
- Does cassandra not a service which accepts data from telnet?
- How do I solve this?