NoHostAvailableException in Cassandra Java Driver when using with Listenable Futures

371 views
Skip to first unread message

Kant Kodali

unread,
Feb 8, 2016, 9:20:53 PM2/8/16
to DataStax Java Driver for Apache Cassandra User Mailing List
http://stackoverflow.com/questions/35266006/could-not-connect-to-cassandra-using-the-latest-cql-driver-and-default-settings

I am using the latest version of cassandra 3.0.2 and the latest version of datastax cassandra core java driver which is 3.0.0. The settings in cassandra.yaml remains unchanged. I have not changed that file. so whatever the default settings are they remain the same. I keep hearing that rpc_address should be 0.0.0.0 but by default it is localhost and the broadcast_rpc_address by default is commmented out however its value is 1.2.3.4 (again by default it is commented out). I have not changed any of the default settings so the cassandra.yaml file remains unchanged. I also don't understand why we need to set rpc_address and all that after all I hear that latest version of cassandra had moved away from rpc?!

Here is the snippet of the code

    Cluster cassandra = Cluster.builder().addContactPoint("localhost").withPort(9042).build();
    ListenableFuture<Session> session = cassandra.connectAsync("demo1");
    ......


Here is the error that I get
   

    error message -> All host(s) tried for query failed (tried: localhost/127.0.0.1:9042 (com.datastax.driver.core.exceptions.ConnectionException: [localhost/127.0.0.1] Timeout while setting keyspace on connection))
    at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84)
    error cause -> com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: localhost/127.0.0.1:9042 (com.datastax.driver.core.exceptions.ConnectionException: [localhost/127.0.0.1] Timeout while setting keyspace on connection))
    at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:37)
    at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
    at com.datastax.driver.core.AbstractSession.prepare(AbstractSession.java:98)
    at com.datastax.driver.mapping.Mapper.getPreparedQuery(Mapper.java:118)
    at com.datastax.driver.mapping.Mapper.getPreparedQuery(Mapper.java:129)
    at com.datastax.driver.mapping.Mapper.getQuery(Mapper.java:333)
    at com.datastax.driver.mapping.Mapper.getQuery(Mapper.java:325)
    at com.datastax.driver.mapping.Mapper.getAsync(Mapper.java:388)

Here is where the exeption happens in cassandra driver 

        stmt = session().prepare(queryString); //Mapper.java

        public PreparedStatement prepare(String query) { //AbstractSession.java
        try {
            return Uninterruptibles.getUninterruptibly(prepareAsync(query));
        } catch (ExecutionException e) {
            throw DriverThrowables.propagateCause(e);
        }
    }

Olivier Michallat

unread,
Feb 10, 2016, 6:17:47 AM2/10/16
to java-dri...@lists.datastax.com
That sounds like JAVA-1002, which I haven't reproduced yet. Can you connect with cqlsh?

--

Olivier Michallat

Driver & tools engineer, DataStax


--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.

Reply all
Reply to author
Forward
0 new messages