I cannot cqlsh to remote host
./cqlsh xx.xx.x.xxx 9042
Connection error: ('Unable to connect to any servers', {'10.101.33.163':
ConnectionException(u'Did not get expected SupportedMessage response;
instead, got: <ErrorMessage code=0000 [Server error]
message="io.netty.handler.codec.DecoderException:
org.apache.cassandra.transport.ProtocolException: Invalid or unsupported
protocol version: 4">',)})
I am using cqlsh 5.0.1 and python 2.7.10
./cqlsh --version
cqlsh 5.0.1
python -V
Python 2.7.10
I am on mac and used the instructions from http://www.datastax.com/2012/01/working-with-apache-cassandra-on-mac-os-x to download cassandra.
Cassandra on my local is 2.2.1(as I understand from the zip file) and it appears like cassandra on remote host is NOT 2.2.1 (I assume it is either 2.0 or 2.1). Without definitively knowing what the version is on remote host, how can I try to connect to cassandra on remote host
1) Make sure the service is running:
$ ps aux | grep cassandra
Example:
106 7387 5.1 70.9 2019816 1454636 ? SLl Sep02 16:39 /usr/lib/jvm/java-7-oracle/jre//bin/java -Ddse.system_cpu_cores=2 -Ddse.system_memory_in_mb=2003 -Dcassandra.config.loader=com.datastax.bdp.config.DseConfigurationLoader -Ddse.system_cpu_cores=2 -Ddse.system_memory_in_mb=2003 -Dcassandra.config.loader=com.datastax.bdp.config.DseConfigurationLoader -ea -javaagen...
2) Make sure you are using the correct IP by checking the server config:
$ ifconfig
Example:
eth1 Link encap:Ethernet HWaddr 08:00:27:a6:4e:46
inet addr:192.168.56.10 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fea6:4e46/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
3) Ensure you can connect to that IP from the server you are on:
$ ssh user@xxx.xxx.xx.xx
4) Check the node's status and also confirm it shows the same IP:
$nodetool status
5) run the command to connect with the IP (only specify port if you are not using the default):
$ cqlsh xxx.xxx.xx.xx
You might need to put cqlsh from 2.1 or 2.0 on your mac to match the server you are trying to connect to. So that's what I'd try first.
I was experiencing the same error (running Cassandra 2.2.0 on Windows 8.1), and found a workaround by Gustav Grusell that worked for me: https://issues.apache.org/jira/browse/CASSANDRA-9467?focusedCommentId=14693410&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14693410
The workaround he presents is to modify your cqlsh.py script to accept a protocol version. After making these changes, you will be able to specify protocol version 3 (for example) by passing --protocolversion=3
to cqlsh.
Locate cqlsh.py
in your Cassandra bin folder and back it up before making these changes.
Add the following line alongside the other parser.add_option
statements (~line 175):
parser.add_option("--protocolversion", default=DEFAULT_PROTOCOL_VERSION, help='Specify protocol version (default: %default).')
Add the following alongside the other optvalues under def read_options(cmdlineargs, environment):
(~line 2520):
optvalues.protocolversion = option_with_default(configs.get, 'cql', 'protocolversion', DEFAULT_PROTOCOL_VERSION)
Add the following before the return statement in def read_options(cmdlineargs, environment):
(~line 2574)
if options.protocolversion:
try:
options.protocolversion = int(optvalues.protocolversion)
except ValueError:
options.protocolversion=DEFAULT_PROTOCOL_VERSION
Modify the Shell command in def main(options, hostname, port):
to include the protocol version (~line 2657):
connect_timeout=options.connect_timeout,
protocol_version=options.protocolversion)
Here's what my cqlsh.py now looks like: http://pastebin.com/f9D2zEE4