question

devopsdymyr_180369 avatar image
devopsdymyr_180369 asked Erick Ramirez edited

Cluster.init called with contact_points specified, but no load_balancing_policy

Hi have some issue to connect my cassandra from my python connector

Connotor.py contain below code

from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
from cassandra import ReadTimeout
import os

class CassandraConnection():

    def getConnection():
        auth_provider = PlainTextAuthProvider(username ='admin', password='Dog2019')
        cluster=Cluster(['a5ad8e558c23e9a524-1196365.us-west-2.elb.amazonaws.com'], auth_provider=auth_provider)

        session = cluster.connect()
        session.set_keyspace('tonnage')
        cluster.connect()

        return session

While run my python code getting this error

WARNING:

cassandra.cluster:Cluster.init called with contact_points specified, but no load_balancing_policy. In the next major version, this will raise an error; please specify a load-balancing policy. (contact_points = ['a5ad8e558c23e9a524-1196365.us-west-2.elb.amazonaws.com'], lbp = None)

WARNING:

cassandra.pool:Error attempting to reconnect to 100.100.0.3, scheduling retry in 4.0 seconds: [Errno None] Tried connecting to [('100.100.0.3', 9042)]. Last error: timed out

WARNING:

cassandra.pool:Error attempting to reconnect to 100.100.0.2, scheduling retry in 128.0 seconds: [Errno None] Tried connecting to [('100.100.0.2', 9042)]. Last error: timed out

WARNING:

cassandra.pool:Error attempting to reconnect to 100.100.0.2, scheduling retry in 4.0 seconds: [Errno None] Tried connecting to [('100.100.0.2', 9042)]. Last error: timed out

INFO:cassandra.policies:Using datacenter 'datacenter1' for DCAwareRoundRobinPolicy (via host '34.217.153.0'); if incorrect, please specify a local_dc to the constructor, or limit contact points to local cluster nodes INFO:cassandra.cluster:New Cassandra host discovered INFO:cassandra.cluster:New Cassandra host discovered
INFO:cassandra.cluster:Cassandra host 52.26.34.69 removed

python driver
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

@devopsdymyr_180369 You're getting a warning because you have not specified a load balancing policy in the connection properties.

Also, you're using an elastic load balancer in front of Cassandra and it's an anti-pattern. The Cassandra drivers have built-in load balancing features which you need to take advantage of. You need to provide a list of IP addresses instead -- usually, these are the same as the seeds list (though it doesn't have to be the same).

See the Python driver Getting Started guide for more info. Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.