(Migrated) Cassandra example - No such connection

(This message has been automatically imported from the retired mailing list)

Hi,

I was wondering if somebody could help me troubleshoot running the Cassandra
example from the documentation or not?

I’m getting an error trying to connect to the ‘cassy’ Cassandra connection
using the code from the documentation.

I can reach the database from my windows box using port 49154 in this case.
It’s running on Ubuntu server as a Docker container on the same box as zato
docker.

Here is the code from the docs that is deployed as a service (not sure why
the semicolon is missing from the query or if it should be there or not.):

test1.test-service Yes test1.TestService No

from zato.server.service import Service

class TestService(Service):

def handle(self):



    # Obtains a connection the named pool

    conn = self.cassandra_conn['cassy'].conn



    # Executes an ad-hoc query and obtains result

    result = conn.execute('SELECT * FROM schema_columns')



    # Let's find out what we have here..

    for row in result:

        self.logger.info(row)

Invoking and getting error:

zato@32bf993b7dc6:~/env/qs-1/server1/pickup-dir$ zato service invoke
/opt/zato/env/qs-1/server1 test1.test-service

Traceback (most recent call last):

File
"/opt/zato/2.0.2/zato-server/src/zato/server/connection/http_soap/channel.py
", line 198, in dispatch

payload, worker_store, self.simple_io_config, post_data)

File
"/opt/zato/2.0.2/zato-server/src/zato/server/connection/http_soap/channel.py
", line 351, in handle

params_priority=channel_item.params_pri)

File “/opt/zato/2.0.2/zato-server/src/zato/server/service/init.py”,
line 423, in update_handle

raise e

KeyError: u’No such connection cassy in []

Here’s the connection ‘cassy’ that I see.

How it looks in the admin ui. The port is the mapped docker port to the
docker container running Datastax.

                            Name    Active   Contact points   Port


                            cassy     Yes         localhost

49154 Change password Edit Delete

I changed the password to empty. I don’t know how that’s used anyway.

Thanks!

On 24/03/15 22:00, Alex Everitt wrote:

KeyError: u’No such connection cassy in []

Hi Alex,

does it go away when you stop both servers and start them again?

$ zato stop /path/to/server1
$ zato stop /path/to/server2

$ zato start /path/to/server1
$ zato start /path/to/server2

It shouldn’t be required but if it does help, it will narrow the scope
within which to look for the root cause.

thanks,

On 25/03/15 14:26, Alex Everitt wrote:

Anyway, I tried to stop and start the servers and the same error is thrown when trying to invoke the service.
I’m not sure about debugging any of this yet so please bear with me.

Alex, I cannot reproduce the situation.

I’m using Zato 2.0.2 and connecting to Cassandra 2.1.2.

When I create a Cassandra connection definition per documentation …

https://zato.io/docs/web-admin/conn-def/cassandra.html

… I can see that both servers log on INFO level that they have just
connected to the database:

2015-03-25 16:42:53,697 - INFO - 854:Dummy-10 -
zato.server.connection:22 - Connected to Cassandra
Bunch(action=u'100610', cluster_id=1L, contact_points=u'127.0.0.1\r\n', cql_version=None, default_keyspace=u'system', exec_size=2L, id=1L, is_active=True, msg_type=u'0002', name=u'My Connection', old_name=None, password=u'******', port=9042L, proto_version=2L, tls_ca_certs=None, tls_client_cert=None, tls_client_priv_key=None, username=None)

2015-03-25 16:42:53,702 - INFO - 853:Dummy-21 -
zato.server.connection:22 - Connected to Cassandra
Bunch(action=u'100610', cluster_id=1L, contact_points=u'127.0.0.1\r\n', cql_version=None, default_keyspace=u'system', exec_size=2L, id=1L, is_active=True, msg_type=u'0002', name=u'My Connection', old_name=None, password=u'******', port=9042L, proto_version=2L, tls_ca_certs=None, tls_client_cert=None, tls_client_priv_key=None, username=None)

Can you confirm this is the case your end?

When I now execute your service, this is the stuff in logs:

2015-03-25 16:46:25,346 - INFO - 1433:Dummy-26 - cass1.my-service:22 -
{u’index_options’: u’null’, u’index_name’: None, u’keyspace_name’:
u’system_traces’, u’index_type’: None, u’validator’:
u’org.apache.cassandra.db.marshal.UTF8Type’, u’columnfamily_name’:
u’events’, u’component_index’: 1, u’type’: u’regular’, u’column_name’:
u’activity’}

2015-03-25 16:46:25,346 - INFO - 1433:Dummy-26 - cass1.my-service:22 -
{u’index_options’: u’null’, u’index_name’: None, u’keyspace_name’:
u’system_traces’, u’index_type’: None, u’validator’:
u’org.apache.cassandra.db.marshal.TimeUUIDType’, u’columnfamily_name’:
u’events’, u’component_index’: 0, u’type’: u’clustering_key’,
u’column_name’: u’event_id’}

Everything looks fine - can you please confirm in logs you are actually
connecting to the DB?

thanks,

On 25/03/15 18:26, Alex Everitt wrote:

Thanks so much for looking at this. I thought I looked in the
logs but I just missed it.

NoHostAvailable: (‘Unable to connect to any servers’, {u’localhost’: error(111, ‘Connection refused’)})

This has to be because these are separate docker containers and the
ports need to be linked. I just missed the obvious connection error and only
saw the No such connection. Well, duh, there is no such connection because of the connection error.

Ah, I get it. Glad we’ve found it! :slight_smile: