Unable to connect to Cassandra remotely using DataStax Python driver -
i'm having trouble connecting cassandra (running on ec2 node) remotely (from laptop). when use datastax python driver cassandra:
from cassandra.cluster import cluster cluster = cluster(['10.x.x.x'], port=9042) cluster.connect()
i get:
traceback (most recent call last): file "/users/user/virtualenvs/test/lib/python2.7/site-packages/ipython/core/interactiveshell.py", line 3035, in run_code exec(code_obj, self.user_global_ns, self.user_ns) file "<ipython-input-23-dc85f20fd4f5>", line 1, in <module> session = cluster.connect() file "/users/user/virtualenvs/test/lib/python2.7/site-packages/cassandra/cluster.py", line 755, in connect self.control_connection.connect() file "/users/user/virtualenvs/test/lib/python2.7/site-packages/cassandra/cluster.py", line 1868, in connect self._set_new_connection(self._reconnect_internal()) file "/users/user/virtualenvs/test/lib/python2.7/site-packages/cassandra/cluster.py", line 1903, in _reconnect_internal raise nohostavailable("unable connect servers", errors) nohostavailable: ('unable connect servers', {'10.x.x.x': operationtimedout('errors=none, last_host=none',)})
but cassandra running because nodetool status
gives me:
un 127.0.0.1 124.18 kb 256 100.0% 4d973e17-ae08-3aa1-81d2-605b92753694 rack1
cassandra seems listening on port 9042:
netstat -nltp | grep 9042 tcp6 0 0 0.0.0.0:9042 :::* listen -
and can telnet laptop cassandra:
$ telnet 10.x.x.x 9042 trying 10.x.x.x... connected ip-10-x-x-x. escape character '^]'.
relevant highlights cassandra.yaml:
start_native_transport: true rpc_address: 0.0.0.0 rpc_port: 9160 broadcast_rpc_address: 10.x.x.x
/var/log/cassandra/system.log
shows nothing useful.
edit: can connect cassandra using cqlsh 127.0.0.1 9042
on server, , cqlsh 10.x.x.x 9042
laptop without problems.
solution
looks 1 place tested script (a python console inside pycharm) is, reason, place script not work. no problems running script in pycharm or in python/ipython interactive mode. leave question, contains complete checklist python-to-cassandra connection troubleshooting.
here simple debug method you: on machine has cassandra installed, using cassandra cli command "cqlsh 10.x.x.x" connect remote cassandra server. if failed , should modify cassandra configuration file cassandra remote mode.
Comments
Post a Comment