1

I have Cassandra 3.x on my Linux machine. I try to connect to it with https://github.com/tschellenbach/Stream-Framework

from stream_framework.feeds.cassandra import CassandraFeed

I can connect to Cassandra from command line cqlsh' and usingDBeaver GUI` on port 9042.

When I try to run Django with above import I get this error:

cassandra.cluster.NoHostAvailable: 
('Unable to connect to any servers', 
{'::1': error(111, "Tried connecting to [('::1', 9042, 0, 0)]. 
Last error: Connection refused"), 
'127.0.0.1': error(111, 
"Tried connecting to [('127.0.0.1', 9042)]. 
Last error: Connection refused")})

EDIT 3 When all settings are to default values i get also

 DriverException('ProtocolError returned from
 server while using explicitly set client protocol_version 2',)})

I've looked round for a solution and changed /etc/cassandra/cassandra.yaml to:

rpc_address: 0.0.0.0 #from localhost
rpc_port: 9042 #from 9160
listen_address: 127.0.0.1 #from localhost

But it hasn't helped.

Any ideas on how to solve it?

EDIT I turned things to defaul settings and netstat -nat | grep 9042

tcp        0      0 127.0.0.1:56524         127.0.0.1:9042          ESTABLISHED
tcp        0      0 127.0.0.1:56528         127.0.0.1:9042          ESTABLISHED
tcp        0      0 127.0.0.1:56522         127.0.0.1:9042          ESTABLISHED
tcp        0      0 127.0.0.1:56558         127.0.0.1:9042          ESTABLISHED
tcp        0      0 127.0.0.1:56516         127.0.0.1:9042          ESTABLISHED
tcp        0      0 127.0.0.1:56514         127.0.0.1:9042          ESTABLISHED
tcp        0      0 127.0.0.1:56560         127.0.0.1:9042          ESTABLISHED
tcp        0      0 127.0.0.1:56530         127.0.0.1:9042          ESTABLISHED
tcp6       0      0 127.0.0.1:9042          :::*                    LISTEN
tcp6       0      0 127.0.0.1:9042          127.0.0.1:56516         ESTABLISHED
tcp6       0      0 127.0.0.1:9042          127.0.0.1:56514         ESTABLISHED
tcp6       0      0 127.0.0.1:9042          127.0.0.1:56528         ESTABLISHED
tcp6       0      0 127.0.0.1:9042          127.0.0.1:56558         ESTABLISHED
tcp6       0      0 127.0.0.1:9042          127.0.0.1:56524         ESTABLISHED
tcp6       0      0 127.0.0.1:9042          127.0.0.1:56560         ESTABLISHED
tcp6       0      0 127.0.0.1:9042          127.0.0.1:56522         ESTABLISHED
tcp6       0      0 127.0.0.1:9042          127.0.0.1:56530         ESTABLISHED

Btw, nodetool status returns

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns (effective)  Host ID                               Rack
UN  127.0.0.1  157.61 KB  256          100.0%            3b13b3f2-968d-4f53-8e9b-1aa4ae271c66  rack1

EDIT 2
I'm not sure if this is some kind of a clue but when i connect to Cassandra with DBeaver i get only one host listed:

0:0:0:0:0:0:0:1

Is it IPv6 instead of IPv4?

Mike
  • 465
  • 5
  • 14

1 Answers1

2

I found problem. Default settings of Stream-Framework for Cassandra Protocol is 2 https://github.com/tschellenbach/Stream-Framework/blob/master/stream_framework/default_settings.py#L23

after changing it to 4, the tests and app connect to Cassandra insatnce.

Edit

The change is in settings.py of main project. Like this:

CASSANDRA_DRIVER_KWARGS = { 'protocol_version': 4 }

Mike
  • 465
  • 5
  • 14