Can't connect to cassandra : NodeContext killing all pooled connections for session
When I try to connect to cassandra within my java application I receive the exception at the end of this message. I am using pelops library to access database. Database is working on linux and my development environment is on windos 7. Intresting line is
WARNING: 10.0.0.7 NodeContext killing all pooled connections for session 44
10.0.0.7 is the IP of the cassandra node. And I can connect this node with cassandra-cli. After a few hours of googling I decided to ask, what i am doing wrong? Complete stack trace is below.
SEVERE: org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused: connect at org.apache.thrift.transport.TSocket.open(TSocket.java:185) at org.wyki.cassandra.pelops.ThriftPool$Connection.open(ThriftPool.java:329) at org.wyki.cassandra.pelops.ThriftPool$NodeContext.createConnection(ThriftPool.java:438) at org.wyki.cassandra.pelops.ThriftPool$NodeContext.access$5(ThriftPool.java:429) at org.wyki.cassandra.pelops.ThriftPool$NodeContext$1.run(ThriftPool.java:494) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182开发者_JS百科) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at java.net.Socket.connect(Socket.java:478) at org.apache.thrift.transport.TSocket.open(TSocket.java:180) ... 7 more
WARNING: 10.0.0.7 NodeContext killing all pooled connections for session 44
"Connection refused" means that Cassandra isn't listening on the interface you're connecting to. By default Cassandra listens on port 9160 on localhost. You will need to change that if you want to connect externally; read the comments for ThriftAddress in the configuration file.
Pelops isn't doing anything remotely tricky when it comes to making connections to Cassandra so it seems very unlikely it's Pelops specific.
I've just had a quick look at the Hector connection code and it looks pretty much the same: https://github.com/rantav/hector/blob/master/core/src/main/java/me/prettyprint/cassandra/connection/HThriftClient.java
The cassandra-cli code looks pretty much the same as well: https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/cli/CliMain.java#L57
p.s. Cassandra should not be configured to listen on 0.0.0.0. See the "Why can't I make Cassandra listen on 0.0.0.0 (all my addresses)?" on the Cassandra FAQ.
It seems that this is a problem with pelops, which is a library on top of cassandra's thrift client. It has some problems for connection to Cassandra working on linux and client on a windows machine.
I've got the same exception connecting with "any" client to cassandra remotely:
ConnectException: Connection refused
Looking through SO I couldn't find a quick solution for that, just reading carefully through cassandra docs and comments within cassandra.yaml - they are very handy!
So for me worked following: change rpc_address value to the hostname or ipaddress you are using to connect to the cassandra instance with the client
精彩评论