這裏是我的代碼:卡桑德拉蟒蛇驅動程序會自動降級PROTOCOL_VERSION不起作用
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()
上面的代碼將產生一個異常的打擊:
[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"',)})
不過,如果我添加了「PROTOCOL_VERSION = 3「,它的工作原理。
每Python Cassandra Driver official document,protocal_version可以自動降級,
協商版本如果在構造函數中沒有設置,驅動程序會自動降級基於與服務器
但爲什麼自動降級不會在這裏發生?我需要這個特性,因爲我想連接到許多不同版本的cassandra集羣,所以我不想爲每個連接設置protocal_version。
這正是現在正在發生的事情!我的版本是2.1.2,但CASSANDRA-9451的問題在2.1.6中修復。 – zhihuifan