I am using cassandra standalone, the machine is up, I was monitoring the cassandra seeing the system.log but I didn’t see anything wrong.
I’ve captured the flow of packets using wireshark and I’ve seen that the cassandra server is reset the connection with the client. I am sending the python app which I am using.

#!/usr/bin/env python

# Copyright 2013-2015 DataStax, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
import threading

log = logging.getLogger()
log.setLevel('DEBUG')
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s"))
log.addHandler(handler)

from cassandra import ConsistencyLevel
from cassandra.io.libevreactor import LibevConnection
from cassandra.cluster import Cluster
from cassandra.query import SimpleStatement

KEYSPACE = "testkeyspace"

thread_local = threading.local()

def get_session():
    if hasattr(thread_local, "cassandra_session"):
	return thread_local.cassandra_session
 
    cluster = Cluster(['10.20.255.191'])
    cluster.connection_class = LibevConnection
    session = cluster.connect()

    thread_local.cassandra_session = session 
   
    log.info("EDUARDOCOSTAALFAIA")
    return session


def main_edu():

    log.info("creating keyspace...")
    get_session("""
    	CREATE KEYSPACE IF NOT EXISTS %s
        WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '2' }
        """ % KEYSPACE)

    log.info("setting keyspace...")
    get_session(KEYSPACE)

    log.info("creating table...")
    get_session("""
        CREATE TABLE IF NOT EXISTS mytable (
            thekey text,
            col1 text,
            col2 text,
            PRIMARY KEY (thekey, col1)
        )
        """)



def main():
    cluster = Cluster(['10.20.255.191'])
    cluster.connection_class = LibevConnection
    #session = cluster.connect()
    session = get_session()
    
 
    log.info("creating keyspace...")
    session.execute("""
        CREATE KEYSPACE IF NOT EXISTS %s
        WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '2' }
        """ % KEYSPACE)

    log.info("setting keyspace...")
    session.set_keyspace(KEYSPACE)

    log.info("creating table...")
    session.execute("""
        CREATE TABLE IF NOT EXISTS mytable (
            thekey text,
            col1 text,
            col2 text,
            PRIMARY KEY (thekey, col1)
        )
        """)

    query = SimpleStatement("""
        INSERT INTO mytable (thekey, col1, col2)
        VALUES (%(key)s, %(a)s, %(b)s)
        """, consistency_level=ConsistencyLevel.ONE)

    prepared = session.prepare("""
        INSERT INTO mytable (thekey, col1, col2)
        VALUES (?, ?, ?)
        """)

    for i in range(10):
        log.info("inserting row %d" % i)
        session.execute(query, dict(key="key%d" % i, a='a', b='b'))
        session.execute(prepared, ("key%d" % i, 'b', 'b'))

    future = session.execute_async("SELECT * FROM mytable")
    log.info("key\tcol1\tcol2")
    log.info("---\t----\t----")

    try:
        rows = future.result()
    except Exception:
        log.exception("Error reading rows:")
        return

    for row in rows:
        log.info('\t'.join(row))

    session.execute("DROP KEYSPACE " + KEYSPACE)

if __name__ == "__main__":
   main()
    # main_edu()

On 29 Oct 2015, at 00:52, Surbhi Gupta <[email protected]> wrote:

Hi Eduardo,

Is the cluster up and running?
As your message says "Control connection failed to connect, shutting down Cluster"

May be you can get some more info from the system.log.

Thanks
Surbhi

On 28 October 2015 at 16:46, Eduardo Alfaia <[email protected]> wrote:
Hi Gupta,

I am running a simple python application that isn’t heavy from point of view of access to cassandra. The application create a new keyspace, tables and do the load of data.
The application is an example in python-driver folder.


On 29 Oct 2015, at 00:33, Surbhi Gupta <[email protected]> wrote:

Are you running heavy load?
I have seen these kinds error application team reporting to us in case when they have too many connection already setup and they are trying to connect more applications. 

Try to disconnect the applications which are not required and try again ..
Hope this helps...

On 28 October 2015 at 16:22, Eduardo Alfaia <[email protected]> wrote:
Hi Guys,

I am some problems of  Connection Timeout in a random mode, that is, the application in python that I am using sometimes it does work very well sometimes not, I am getting this error:

015-10-28 19:49:05,286 [WARNING] cassandra.cluster: [control connection] Error connecting to 10.20.255.191:
Traceback (most recent call last):
  File "/home/ealfaia/workspace_patrizio/python-driver/cassandra/cluster.py", line 2117, in _reconnect_internal
    return self._try_connect(host)
  File "/home/ealfaia/workspace_patrizio/python-driver/cassandra/cluster.py", line 2164, in _try_connect
    self._refresh_schema(connection, preloaded_results=shared_results, schema_agreement_wait=-1)
  File "/home/ealfaia/workspace_patrizio/python-driver/cassandra/cluster.py", line 2343, in _refresh_schema
    responses = connection.wait_for_responses(*queries, timeout=self._timeout, fail_on_error=False)
  File "/home/ealfaia/workspace_patrizio/python-driver/cassandra/connection.py", line 438, in wait_for_responses
    return waiter.deliver(timeout)
  File "/home/ealfaia/workspace_patrizio/python-driver/cassandra/connection.py", line 839, in deliver
    raise OperationTimedOut()
OperationTimedOut: errors=None, last_host=None
2015-10-28 19:49:05,292 [ERROR] cassandra.cluster: Control connection failed to connect, shutting down Cluster:
Traceback (most recent call last):
  File "/home/ealfaia/workspace_patrizio/python-driver/cassandra/cluster.py", line 840, in connect
    self.control_connection.connect()
  File "/home/ealfaia/workspace_patrizio/python-driver/cassandra/cluster.py", line 2091, in connect
    self._set_new_connection(self._reconnect_internal())
  File "/home/ealfaia/workspace_patrizio/python-driver/cassandra/cluster.py", line 2126, in _reconnect_internal
    raise NoHostAvailable("Unable to connect to any servers", errors)
NoHostAvailable: ('Unable to connect to any servers', {'10.20.255.191': OperationTimedOut('errors=None, last_host=None',)})

I have had some tests with others applications in python and the same error occur. Does anyone have any idea?

Thanks a lot




Reply via email to