Our earlier blog post talked about using the Neo4j web browser along with embedded Neo4j. The WrappingNeoServerBootstrapper
which was employed to do this has been deprecated for a while and it raises questions about the alternative.
Testing server extensions is now possible (see Testing your extension) but there is still another use case for wanting to connect to an embedded graph – troubleshooting.
Perhaps you have a web application running in production with Neo4j in embedded mode and you’ve got to troubleshoot an issue which requires access to the graph – how do you do this against a live graph?
Well, there is another option which won’t give you access to the pretty browser, but it will allow you to run queries via the shell.
Enable the remote shell
GraphDatabaseServicedb=newGraphDatabaseFactory().newEmbeddedDatabaseBuilder(DB_DIR).setConfig(ShellSettings.remote_shell_enabled,"true").setConfig(ShellSettings.remote_shell_port,"5555").newGraphDatabase
Now we have the shell enabled, connect to your graph using
neo4j-shell -port 5555
Don’t want to modify data by mistake? Start the shell in read only mode with
.setConfig(ShellSettings.remote_shell_read_only, "true")
Of course, make sure that access to the shell is controlled. By default, the shell listens only on the loopback interface but it can be configured to listen on another IP by setting the value of ShellSettings.remote_shell_host