Sabarish Sathasivan
Sabarish Sathasivan

Reputation: 1266

Cassandra Java Driver error - All host(s) tried for query failed Connection has been closed

All,

I have a 3 noded cluster cassandra in Digital Ocean . the version of cassandra as per SHOW VERSION in CQL is shown below

[cqlsh 5.0.1 | Cassandra 3.0.0 | CQL spec 3.3.1 | Native protocol v4]

I am able to connnect to one node of the cluster from another node using cqlsh and run commands... However when i try to connect using the java driver , i get the following exception

com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /128.xxx.xxx.xx:9042 (com.datastax.driver.core.TransportException: [/128.xxx.xxx.xxx:9042] Connection has been closed))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:222)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:77)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1232)
at com.datastax.driver.core.Cluster.getMetadata(Cluster.java:336)
at com.attinad.cantiz.iot.platform.vehicledatapoc.App.connect(App.java:22)
at com.attinad.cantiz.iot.platform.vehicledatapoc.App.main(App.java:14)

The version of java driver that i am using is 2.0.10. The maven configuration is given below

<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>2.0.10</version>
</dependency>

I checked the cassandra.yaml and found that the following settings has been set correctly

start_native_transport: true
native_transport_port: 9042
rpc_address: 128.xxx.xxx.xx
listen_address: 128.xxx.xxx.xx

has been configured correctly... So i am completely lost... Any help is appreciated

Upvotes: 4

Views: 12803

Answers (2)

Adam Morgan
Adam Morgan

Reputation: 495

Ran into this myself... had tried Cassandra 3.0.0 with driver 2.1.9.

Fixed it by going to driver 3.0.0.

Upvotes: 0

Michael Koch
Michael Koch

Reputation: 1242

According to the 2.0.10 driver documentation, that version of the driver is compatible with Apache Cassandra 1.2 and 2.0. Compatibility with 3.0 is added in the 3.0 driver, which is currently at 3.0.0-beta1. The protocol compatibility error should be shown in the Cassandra server logs.

You could either downgrade Cassandra to a 2.x version or try out the beta driver. Downgrading Cassandra should be the safer choice if you want to use the system in production now.

Upvotes: 5

Related Questions