Question

What might I be missing? I'm Unable to connect using python Cassandra-Driver however I seem to be able to connect fine when using the CQL module.

cluster = Cluster(
contact_points=['10.x.x.xx',],
port=9160)

session = cluster.connect()
session.set_keyspace("mykeyspace")

Output:

cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'10.0.x.xx': ConnectionShutdown('Connection to 10.0.x.xx is closed',)})

Also, I'm hosting cassandra from a virtual machine with a single node if that matters.

Was it helpful?

Solution

The DataStax Python driver (which is what it looks like you are using) is using the native protocol and that uses the 9042 port by default. If you checking your conf file (cassandra.yaml), make sure you have the start_native_transport: true (default value since 1.2)

OTHER TIPS

To use the native protocol with the Cassandra driver is totally true. Please note that this Driver (in the Version 2 and in all languages existing) is the only means to use the native protocol -- as of today. When you're using CQLSH please keep using the old THRIFT protocol on port 9160.

To use either port from remote machines update in your cassandra.yaml the corresponding IPs from 127.0.0.1 (default) to 0.0.0.0. This will basically allow any machine to contact THRIFT/NATIVE from remote addresses. These are two separate settings so you can adjust just one or the other. When enabling this make sure to have locked Cassandra with a PasswordAuthenticator (default is none / open to anybody)! Depending on the network type on your VM opening for remote access may not be neccessary e.g. for NAT types.

On my Red Hat by default the firewall had not to be adjusted. Opening NATIVE port to remote hosts was enough to connect from anywhere using credentials.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top