I have a flask app that uses neo4j for some data. Everything runs fine locally when I use the python server, but when I deploy on nginx+uwsgi, I can no longer execute cypher queries in py2neo. I can't tell whether the miscommunication is at the py2neo level, or nginx permissions or something like that. (I'm running neo4j on the same box as flask, to start.)
The curious thing is that the query otherwise works, and the index it says does not exist ("organization"), actually does exist when I use the neo4j console. Here's the error:
File "/var/www/newproj/newproj/view_helpers.py", line 333, in tile_portfolios
X = cypher.execute(cdb,query)[0]
File "/usr/local/lib/python2.7/dist-packages/py2neo/cypher.py", line 261, in execute
params, row_handler=row_handler, metadata_handler=metadata_handler, error_handler=error_handler
File "/usr/local/lib/python2.7/dist-packages/py2neo/cypher.py", line 118, in execute
stacktrace=err.stacktrace,
CypherError: (u'Index `organization` does not exist', u'MissingIndexException', [u'org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$.checkNodeIndex(IndexQueryBuilder.scala:120)', u'org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$.getNodeGetter(IndexQueryBuilder.scala:87)', u'org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder.createStartPipe(IndexQueryBuilder.scala:62)', u'org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder.apply(IndexQueryBuilder.scala:38)', u'org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.prepareExecutionPlan(ExecutionPlanImpl.scala:45)', u'org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.<init>(ExecutionPlanImpl.scala:31)', u'org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:67)', u'org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:67)', u'org.neo4j.cypher.internal.LRUCache$LazyValue.value(LRUCache.scala:27)', u'org.neo4j.cypher.internal.LRUCache.getOrElseUpdate(LRUCache.scala:39)', u'org.neo4j.cypher.ExecutionEngine.prepare(ExecutionEngine.scala:67)', u'org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:59)', u'org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:63)', u'org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:79)', u'org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:64)', u'java.lang.reflect.Method.invoke(Method.java:616)'])
And here's the reason I'm sure the index it says doesn't exist does actually exist:
neo4j-sh (?)$ index --indexes
Node indexes:
vertex
organization
Relationship indexes:
edge
neo4j-sh (?)$ index --get-config organization
{
"provider": "lucene",
"type": "exact"
}
So, is this something I should check out in the cypher.py file? Or does this look like a permissions problem that perhaps nginx can't read responses from locahost:7474 when it's not being run by the python server? Oddly, other aspects of py2neo do work correctly on the server, such as neo4j.GraphDatabaseService("http://localhost:7474/db/data/").get_or_create_indexed_node()
Any help in debugging (or filing an bug report to whichever of these excellent projects is appropriate?) is greatly appreciated.
sudo tcpdump -X -i<interface> -s 65535 tcp port 7474
you may also need to add-v
; the protocol may be very complex at the lower level, so starting higher may be a better option. nginx is probably not to be blamed as it's merely a reverse proxy against uwsgi. Try tracing the requests/responses at thelocal_client
level instead. Sprinkle it withprint
s and look at the uwsgi logs. Try another client github.com/versae/neo4j-rest-client and compare results. – Culmiferous