Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python cassandra driver: Invalid or unsupported protocol version: 4

I get the following error:

   File "clear-domain-cass.py", line 25, in <module>
    session = cluster.connect('my_domain')
  File "/usr/lib/python2.6/dist-packages/cassandra/cluster.py", line 839, in connect
    self.control_connection.connect()
  File "/usr/lib/python2.6/dist-packages/cassandra/cluster.py", line 2075, in connect
    self._set_new_connection(self._reconnect_internal())
  File "/usr/lib/python2.6/dist-packages/cassandra/cluster.py", line 2110, in _reconnect_internal
    raise NoHostAvailable("Unable to connect to any servers", errors)
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'10.1.0.89': ConnectionException(u'Failed to initialize new connection to 10.1.0.89: code=0000 [Server error] message="io.netty.handler.codec.DecoderException: org.apache.cassandra.transport.ProtocolException: Invalid or unsupported protocol version: 4"',)})

This is the relevant bit of script:

from cassandra.cluster import Cluster
from cassandra.query import BatchStatement

startTime = time.time()

if len(sys.argv) < 2:
  print "Target host IP is required arg for this script. A comma-sep. list will work also"
  exit()

if len(sys.argv) < 3:
  print "Target domain is required arg for this script."
  exit()

hostIp = sys.argv[1]
domain = str(sys.argv[2])

cluster = Cluster(
  contact_points=[hostIp],
)
session = cluster.connect('my_domain')

It fails on the cluster.connect line.

I installed pip into this Amazon EC2 instance by following these steps: http://bcjordan.com/pip-on-amazon-ec2/

like image 447
mtyson Avatar asked Jul 16 '15 01:07

mtyson


1 Answers

The version of the python driver you're using attempts to use the v4 native protocol by default, but Cassandra 2.1 only supports protocol versions 3 and lower. To tell the driver to use the v3 protocol, do the following:

cluster = Cluster(contact_points=[hostIp], protocol_version=3)

(By the way, the error message for this should be improved in Cassandra 2.1.6+ thanks to CASSANDRA-9451).

like image 125
Tyler Hobbs Avatar answered Oct 07 '22 12:10

Tyler Hobbs