Hier ist mein Code:cassandra Python-Treiber automatisch Herabstufung protocol_version nicht
from cassandra.cluster import Cluster
import cassandra
print('cassandra driver version: %s ' % str(cassandra.__version_info__))
# c = Cluster(['mgdevtestslc03-7583.slc07.dev.xxx.com'], protocol_version=3)
c = Cluster(['mgdevtestslc03-7583.slc07.dev.xxx.com'])
c.connect()
Der obige Code wird eine Ausnahme als Schlag erzeugen:
[email protected]:~$ python 1.py
cassandra driver version: (3, 8, 0)
Traceback (most recent call last):
File "1.py", line 7, in <module>
c.connect()
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 1172, in connect
self.control_connection.connect()
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 2618, in connect
self._set_new_connection(self._reconnect_internal())
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 2655, in _reconnect_internal
raise NoHostAvailable("Unable to connect to any servers", errors)
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'10.***.***.**': ConnectionException('Failed to initialize new connection to 10.***.***.**: Error from server: code=0000 [Server error] message="io.netty.handler.codec.DecoderException: org.apache.cassandra.transport.ProtocolException: Invalid or unsupported protocol version: 4"',)})
Wenn ich jedoch die „protocol_version hinzufügen = 3 ", es funktioniert.
Per Python Cassandra Driver official document kann protocal_version automatisch sein herabgestuft,
Wenn nicht im Konstruktor gesetzt ist, wird der Treiber automatisch Herabstufung Version basierend auf einer Verhandlung mit dem Server
aber warum das automatische Downgrade hier nicht passiert? Ich benötige diese Funktion, da ich eine Verbindung zu vielen verschiedenen Versionen von Cassandra-Clustern herstellen möchte. Daher möchte ich die Protokollversion für jede Verbindung nicht festlegen.
Genau das passiert jetzt! Meine Version ist 2.1.2, aber das Problem CASSANDRA-9451 ist in 2.1.6 behoben. – zhihuifan