all. I'm new to neo4j and trying to use the official JS driver from node / express to hit a remote (e.g. non-local) server, but keep getting [Error: socket hang up] code: 'ECONNRESET' errors. Code looks like this:
router.get('/', function(req, res, next) {
var driver = neo4j.driver("bolt://ip.address", neo4j.auth.basic("neo4j", "neo4j"));
var session = driver.session();
var query = "MATCH (p:Person {name:'Sally'})-[r:KNOWS]->(f:Person) RETURN f";
session
.run(query)
.then(function(result) {
result.records.forEach(function(record) {
console.log(record._fields);
});
session.close();
})
.catch(function(error) {
console.log(error);
});
driver.close();
});
I've tried both the streaming and promise techniques on both bolt and http, all with the same outcome. Remote server is config'ed to accept external connections and I've verified connectivity separately via golang.
Ideas?
Thanks to Oscar Hane for answering this over on Github:
Your issue is that you're potentially closing the driver before your query are finished.
router.get('/', function(req, res, next) {
var driver = neo4j.driver("bolt://ip.address", neo4j.auth.basic("neo4j", "neo4j"));
var session = driver.session();
var query = "MATCH (p:Person {name:'Sally'})-[r:KNOWS]->(f:Person) RETURN f";
session
.run(query)
.then(function(result) {
result.records.forEach(function(record) {
console.log(record._fields);
});
session.close();
driver.close();
})
.catch(function(error) {
console.log(error);
driver.close();
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With