wenfeng
wenfeng

Reputation: 177

python cassandra driver : Error attempting to reconnect

I use python-cassandra driver, and cassandra cluster is at AWS. There is lots of warning when connecting remotely. Does anyone have same issue?

import cassandra from cassandra.cluster import Cluster ... In [3]:cassandra.version Out[3]:'2.5.1'

WARNING:cassandra.pool:Error attempting to reconnect to 172.31.24.108, scheduling retry in 128.0 seconds: Timed out connecting to 172.31.24.108

Upvotes: 4

Views: 1170

Answers (1)

Dyno Fu
Dyno Fu

Reputation: 9044

i think it is because you cannot connect to 172.31.24.108 (private network?) directly. in my situation, i can only connect to part of the cluster nodes. so what i do is following the document of HostFilterPolicy and create my own filter.

    from cassandra.policies import HostFilterPolicy, RoundRobinPolicy

    CONN_HOSTS = ['172.235.33.32', '172.235.32.155']

    whitelist_filter_policy = HostFilterPolicy(
        child_policy=RoundRobinPolicy(),
        predicate=lambda host: host.address in CONN_HOSTS)
    # ...

    cluster = Cluster(
        contact_points=CONN_HOSTS,
        load_balancing_policy=whitelist_filter_policy,
        cql_version="3.2.1",
        protocol_version=3,
        ssl_options=ssl_options,
        port=9042,
        auth_provider=auth_provider)

Upvotes: 1

Related Questions