com.datastax.driver.core.exceptions.NoHostAvailableException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • i am using cassandra 2.0.9 and datastax java driver 3.0.0. I had too many NoHostAvailableException after some ReadTimeOutException and WriteTimeOutException.NoHostException occurred even though cassandra is normal and listening in 9160 and 9042 ports. It says some connections are closed, if connections are closed then it should establish new connections for processing. i haven't set connectionsPerHost. My code to connect cassandra using driver {code:java} private static Cluster constructCluster(String hostName,String port) { String[] hostNames = hostName.split(","); SocketOptions sOptions = new SocketOptions(); sOptions.setKeepAlive(true); QueryOptions qOptions = new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM) .setFetchSize(500); LatencyAwarePolicy loadBalancingPolicy = LatencyAwarePolicy.builder(DCAwareRoundRobinPolicy.builder().withLocalDc(defaultDC).build()) .build(); Cluster cluster = Cluster.builder() .addContactPoints(hostNames) .withLoadBalancingPolicy(loadBalancingPolicy) .withPoolingOptions(new PoolingOptions()) .withQueryOptions(qOptions) .withReconnectionPolicy(new ConstantReconnectionPolicy(TimeUnit.SECONDS.toMillis(5))) .withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE)) .withSocketOptions(sOptions) .build(); LOGGER.log(Level.SEVERE, "host name {0}", hostName); return cluster; } {code} My exception trace {code:java} com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /192.168.250.151:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.250.151] Connection has been closed), /192.168.249.134:9042 (com.datastax.driver.core.exceptions.OperationTimedOutException: [/192.168.249.134] Timed out waiting for server response), /192.168.250.165:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.250.165] Connection has been closed), /192.168.249.91:9042, /192.168.251.84:9042 [only showing errors of first 3 hosts, use getErrors() for more details]) at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84) 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.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245) at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63) {code} another exception trace {code:java} com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /192.168.249.134:9042 (com.datastax.driver.core.exceptions.OperationTimedOutException: [/192.168.249.134] Timed out waiting for server response), /192.168.251.84:9042 (com.datastax.driver.core.exceptions.DriverException: Timeout while trying to acquire available connection (you may want to increase the driver number of per-host connections)), /192.168.250.151:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.250.151] Connection has been closed), /192.168.250.165:9042, /192.168.249.91:9042 [only showing errors of first 3 hosts, use getErrors() for more details]) at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84) 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.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245) at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63) {code} I cannot reproduce this issue later.
    via by Rishikesan,
  • i am using cassandra 2.0.9 and datastax java driver 3.0.0. I had too many NoHostAvailableException after some ReadTimeOutException and WriteTimeOutException.NoHostException occurred even though cassandra is normal and listening in 9160 and 9042 ports. It says some connections are closed, if connections are closed then it should establish new connections for processing. i haven't set connectionsPerHost. My code to connect cassandra using driver {code:java} private static Cluster constructCluster(String hostName,String port) { String[] hostNames = hostName.split(","); SocketOptions sOptions = new SocketOptions(); sOptions.setKeepAlive(true); QueryOptions qOptions = new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM) .setFetchSize(500); LatencyAwarePolicy loadBalancingPolicy = LatencyAwarePolicy.builder(DCAwareRoundRobinPolicy.builder().withLocalDc(defaultDC).build()) .build(); Cluster cluster = Cluster.builder() .addContactPoints(hostNames) .withLoadBalancingPolicy(loadBalancingPolicy) .withPoolingOptions(new PoolingOptions()) .withQueryOptions(qOptions) .withReconnectionPolicy(new ConstantReconnectionPolicy(TimeUnit.SECONDS.toMillis(5))) .withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE)) .withSocketOptions(sOptions) .build(); LOGGER.log(Level.SEVERE, "host name {0}", hostName); return cluster; } {code} My exception trace {code:java} com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /192.168.250.151:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.250.151] Connection has been closed), /192.168.249.134:9042 (com.datastax.driver.core.exceptions.OperationTimedOutException: [/192.168.249.134] Timed out waiting for server response), /192.168.250.165:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.250.165] Connection has been closed), /192.168.249.91:9042, /192.168.251.84:9042 [only showing errors of first 3 hosts, use getErrors() for more details]) at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84) 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.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245) at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63) {code} another exception trace {code:java} com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /192.168.249.134:9042 (com.datastax.driver.core.exceptions.OperationTimedOutException: [/192.168.249.134] Timed out waiting for server response), /192.168.251.84:9042 (com.datastax.driver.core.exceptions.DriverException: Timeout while trying to acquire available connection (you may want to increase the driver number of per-host connections)), /192.168.250.151:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.250.151] Connection has been closed), /192.168.250.165:9042, /192.168.249.91:9042 [only showing errors of first 3 hosts, use getErrors() for more details]) at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84) 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.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245) at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63) {code} I cannot reproduce this issue later.
    via by Rishikesan,
  • GitHub comment 87#264869720
    via GitHub by andrewstevenson
    ,
  • GitHub comment 87#264869105
    via GitHub by alparslanuysal
    ,
    • com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /192.168.250.151:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.250.151] Connection has been closed), /192.168.249.134:9042 (com.datastax.driver.core.exceptions.OperationTimedOutException: [/192.168.249.134] Timed out waiting for server response), /192.168.250.165:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.250.165] Connection has been closed), /192.168.249.91:9042, /192.168.251.84:9042 [only showing errors of first 3 hosts, use getErrors() for more details]) at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84) 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.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245) at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    2 more bugmates