Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to establish a neo4j - bolt driver connection in javascript

I am trying to create a connection between my html embedded javascript and my neo4j database by running the index.html in Chrome. I have reduced the source of the problem to 'neo4j' not being recognised. So the error thrown will be of the type:

Cannot read property ['driver'/'basic'/etc...] of undefined.

In this case I have assumed that 'undefined' is referring to 'neo4j', which would mean that I am not implementing 'neo4j-web.min.js' correctly.

The below block of code is extracted from my index.html and has been taken from: https://www.npmjs.com/package/neo4j-driver

<script src="node_modules/neo4j-driver/lib/browser/neo4j-web.min.js"></script>
<script type="text/javascript" charset="utf-8">
  var driver = neo4j.driver("bolt://localhost:7474", neo4j.auth.basic(neo4j, 
  neo4j));
</script>

Given that the issue seems very localised to this code, I spared everyone the rest of the document. If further context is missing, I'd be happy to provide it.

like image 635
Christopher Mills Avatar asked May 26 '17 15:05

Christopher Mills


People also ask

Can't connect to Neo4j scheme?

Troubleshooting steps: Ensure that the address is correct. Ensure that if the server is listening for bolt connections on a port other than 7687, that you pass the port explicitly to your client (e.g. cypher-shell) or other program you have written. Ensure that firewall rules do not prohibit traffic on the bolt port.

What is Bolt in Neo4j?

Bolt is an application protocol for the execution of database queries via a database query language, such as Cypher. It is generally carried over a regular TCP or WebSocket connection. Bolt inherits its core type system from PackStream, over which its messages are generally carried.

Is Neo4j JavaScript?

The Neo4j JavaScript driver is officially supported by Neo4j and connects to the database using the binary protocol. It aims to be minimal, while being idiomatic to JavaScript, allowing you to subscribe to a stream of responses, errors and completion events.

What languages does Neo4j support?

Neo4j officially supports the drivers for . Net, Java, JavaScript, Go, and Python for the binary Bolt protocol. Our community contributors provide drivers for all major programming languages for all protocols and APIs.


1 Answers

The neo4j-driver module uses an odd system whereby you have to specify which version of the API you want to use.

<script src="node_modules/neo4j-driver/lib/browser/neo4j-web.min.js"></script>
<script type="text/javascript" charset="utf-8">
  neo4j = neo4j.v1
  var driver = neo4j.driver("bolt://localhost:7474", neo4j.auth.basic(neo4j, 
  neo4j));
</script>
like image 143
varbrad Avatar answered Oct 20 '22 01:10

varbrad