cassandra.cqlengine.CQLEngineException: cassandra.cqlengine.connection.cluster is not configured.

49 views
Skip to first unread message

Vaibhav Jain

unread,
Oct 27, 2016, 5:30:23 AM10/27/16
to DataStax Python Driver for Apache Cassandra User Mailing List
Hi There,

 I am running a python(3.4) flask app on aws beanstalk(amazon linux). When I login to ec2 shell and try to run flask app locally, it runs properly and easily fetches data from remote cassandra. 

My env:

 (venv)[ec2-user@ip-11.1.1.1 ~]$ pip freeze
cassandra-driver==3.6.0
click==6.6
Cython==0.24.1
Flask==0.11
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
six==1.10.0
Werkzeug==0.11.11
xmltodict==0.10.2 
But while fetching data from cassandra the app run by AWS eb keep throwing following errors in httpd/error_log.  

ERROR in app: Exception on /user/1003 [GET]
Traceback (most recent call last):
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 1988, in wsgi_app
response = self.full_dispatch_request()
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 1639, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/opt/python/current/app/application.py", line 53, in user_profile
data = get_user_data(id)
File "/opt/python/current/app/application.py", line 163, in get_user_data
if obj:
File "/opt/python/run/venv/lib64/python3.4/site-packages/cassandra/cqlengine/query.py", line 393, in __le
n__
self._execute_query()
File "/opt/python/run/venv/lib64/python3.4/site-packages/cassandra/cqlengine/query.py", line 428, in _exe
cute_query
self._result_generator = (i for i in self._execute(self._select_query()))
File "/opt/python/run/venv/lib64/python3.4/site-packages/cassandra/cqlengine/query.py", line 360, in _exe
cute
result = _execute_statement(self.model, statement, self._consistency, self._timeout)
File "/opt/python/run/venv/lib64/python3.4/site-packages/cassandra/cqlengine/query.py", line 1412, in _ex
ecute_statement
parts = model._routing_key_from_values(key_values, connection.get_cluster().protocol_version)
File "/opt/python/run/venv/lib64/python3.4/site-packages/cassandra/cqlengine/connection.py", line 183, in
 get_cluster
raise CQLEngineException("%s.cluster is not configured. Call one of the setup or default functions firs
t." % __name__)
cassandra.cqlengine.CQLEngineException: cassandra.cqlengine.connection.cluster is not configured. Call one
of the setup or default functions first.


Regards,
Vaibhav 

Alan Boudreault

unread,
Oct 27, 2016, 8:05:48 AM10/27/16
to python-dr...@lists.datastax.com
Vaibhav,

How do you run that application? In addition that the application works when you run it manually, you don´t provide any detail how it actually runs when it fails. Some code could also help us to debug. I assume you do run ´connection.setup()´, so maybe that part of the code is not executed when you run the app the other way. 

Alan 

--
You received this message because you are subscribed to the Google Groups "DataStax Python Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-driver-user+unsub...@lists.datastax.com.



--

Alan Boudreault
Software Engineer (Drivers) | alan.bo...@datastax.com


Vaibhav Jain

unread,
Oct 27, 2016, 11:40:26 AM10/27/16
to python-dr...@lists.datastax.com
Hi Alan,
Thanks for your reply.

My Bad. I was setting the connection with in python __main__ function.  AWS configuration for Elastic Beanstalk configures the WSGI environment (it’s Apache + WSGI in the backend). When it was being run in the EB environment, the main function was getting called. I moved the connection outside main function it started working. 

Thanks,
Vaibhav   

To unsubscribe from this group and stop receiving emails from it, send an email to python-driver-user+unsubscribe@lists.datastax.com.



--

Alan Boudreault
Software Engineer (Drivers) | alan.bo...@datastax.com


Vaibhav Jain

unread,
Oct 27, 2016, 11:43:56 AM10/27/16
to python-dr...@lists.datastax.com
Corrected typos. 

 I was setting the connection with in python __main__ function.  AWS configuration for Elastic Beanstalk configures the WSGI environment (it’s Apache + WSGI in the backend). When it was being run in the EB environment, the main function was not getting called. I moved the connection code outside main function and it started working



To unsubscribe from this group and stop receiving emails from it, send an email to python-driver-user+unsubscribe@lists.datastax.com.


Reply all
Reply to author
Forward
0 new messages