简体   繁体   中英

error on /127.0.0.1 connection (com.datastax.driver.core.TransportException: [/127.0.0.1] Unexpected exception triggered), no more host to try

I am trying to connect Cassandra with Java under Windows Environment. Following are application/OS/lib version.

-Windows 7
-Java 7
-Cassandra 2.1.12

Code:

Cluster clst;
Session ses;
clst= Cluster.builder().addContactPoint("127.0.0.1").withPort(9042).build();

Cassandra and nodetool is running. Below is the status of nodetool.

C:\Program Files\DataStax Community\apache-cassandra\bin>nodetool -h localhost status
Starting NodeTool
Datacenter: datacenter1
========================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens  Owns    Host ID                               Rack
UN  127.0.0.1  245.99 KB  256     ?       61c6b0e5-2f83-4bc9-9b86-6507e2f06dfc  rack1

Note: Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless
C:\Program Files\DataStax Community\apache-cassandra\bin>

When I am trying to connect cassandra with localhost/127.0.01 I and getting below error in stacktrace.

19:19:05.996 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] Refreshing node list and token map
19:19:06.465 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] error on /127.0.0.1 connection (com.datastax.driver.core.TransportException: [/127.0.0.1] Unexpected exception triggered), no more host to try
19:19:06.469 [main] DEBUG com.datastax.driver.core.Cluster - Shutting down
Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/127.0.0.1])
    at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:162)
    at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:83)
    at com.datastax.driver.core.Cluster$Manager.<init>(Cluster.java:516)
    at com.datastax.driver.core.Cluster$Manager.<init>(Cluster.java:473)
    at com.datastax.driver.core.Cluster.<init>(Cluster.java:65)
    at com.datastax.driver.core.Cluster.buildFrom(Cluster.java:93)
    at com.datastax.driver.core.Cluster$Builder.build(Cluster.java:458)
    at cass.Cass.main(Cass.java:16)
Java Result: 1

Also I have tried to find out the solution on stackoverflow also on another sites but got failed to solve my issue.

Does anybody have the some solution for this query?

Please check your rpc_address. I suggest put rpc_address= 0.0.0.0 and broadcast_rpc_address= Listen address could be blank or machine IP

From your stack trace, I suspect that you are using an extremely old version of the Java driver, probably some version from the 1.x series (1.0.1?). Try with the latest 3.0.0 version and see if the error is still there.

I found the problem, I was running the code from a project using a lot of third parties libraries and one of them is causing the error (I don't know which one yet). I replaced the whole jar files and problem solved. Go to the following url and download the Java driver jar files according to your cassandra version you are using. http://docs.datastax.com/en/developer/driver-matrix/doc/javaDrivers.html#java-drivers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM