使用neo4j JS驱动程序进行套接字挂起

时间:2016-09-01 11:28:28

标签: node.js express neo4j

所有。我是neo4j的新手,并尝试使用来自node / express的官方JS驱动程序来命中远程(例如非本地)服务器,但不断收到[错误:套接字挂断]代码:' ECONNRESET&# 39;错误。代码如下所示:

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();
});

我已经在bolt和http上尝试了流媒体和承诺技术,所有这些都有相同的结果。配置远程服务器以接受外部连接,并通过golang单独验证连接。

想法?

1 个答案:

答案 0 :(得分:15)

感谢Oscar Hane在Github上回答这个问题:

  

您的问题是,您可能在关闭之前关闭了驱动程序   查询完成。

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();
    });
});