motiver
motiver

Reputation: 2202

cqlsh errors when connecting to Cassandra on localhost port 9042 binary protocol mode

I just started learning cassandra and I am running into issues with cqlsh. I am running Cassandra 2.2.2 and cqlsh 4.1.1. I my Cassandra.yaml file I set the start_rpc: false as do not want to use the Thrift protocol.

Cassandra starts fine but when I run cqlsh command I get:

Connection error: Could not connect to localhost:9160

I realized I should probably connect to port 9042 as I am not using Thrift. So I changed my command to:

cqlsh localhost 9042

I get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/cqlsh", line 2044, in <module>
    main(*read_options(sys.argv[1:], os.environ))
  File "/usr/local/bin/cqlsh", line 2030, in main
    display_float_precision=options.float_precision)
  File "/usr/local/bin/cqlsh", line 480, in __init__
    cql_version=cqlver, transport=transport)
  File "/usr/local/lib/python2.7/site-packages/cql/connection.py", line 143, in connect
    consistency_level=consistency_level, transport=transport)
  File "/usr/local/lib/python2.7/site-packages/cql/connection.py", line 59, in __init__
    self.establish_connection()
  File "/usr/local/lib/python2.7/site-packages/cql/thrifteries.py", line 159, in establish_connection
    self.remote_thrift_version = tuple(map(int, self.client.describe_version().split('.')))
  File "/usr/local/lib/python2.7/site-packages/cql/cassandra/Cassandra.py", line 1255, in describe_version
    return self.recv_describe_version()
  File "/usr/local/lib/python2.7/site-packages/cql/cassandra/Cassandra.py", line 1265, in recv_describe_version
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
  File "/usr/local/lib/python2.7/site-packages/thrift/protocol/TBinaryProtocol.py", line 126, in readMessageBegin
    sz = self.readI32()
  File "/usr/local/lib/python2.7/site-packages/thrift/protocol/TBinaryProtocol.py", line 206, in readI32
    buff = self.trans.readAll(4)
  File "/usr/local/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 63, in readAll
    raise EOFError()
EOFError

Am I doing anything wrong? Please advise.

Adding more details from cassandra.yaml:

rpc_address: localhost
listen_address: localhost

broadcast_rpc_address is not set. it is commented out. It guess that's the default/

Upvotes: 2

Views: 1496

Answers (1)

Aaron
Aaron

Reputation: 57748

In your cassandra.yaml, what are the values of listen_address, rpc_address, and broadcast_rpc_address? You should be connecting cqlsh to the IP that is specified in one of those.

Do you have multiple versions of Cassandra installed? I only ask because cqlsh automatically connects via 9042 as of Cassandra 2.1, so you shouldn't need to specify it.

If you have an older version that was installed via a package installer (apt-get, yum) then simply running cqlsh will call the old one, and you'll need to specify your complete path to call the correct one for your new version.

I'm mentioning this, because cqlsh 4.1.1 was delivered with Cassandra 2.0.11 and DSE 4.6.0. If you really do have Cassandra 2.2, then your cqlsh version should be at least 5.0.

Bottom line, is to make sure that you are using the cqlsh that was delivered with your version of Cassandra.

Upvotes: 2

Related Questions