node.js - 使用 node.js 发布到 Neo4j 服务器

标签 node.js azure neo4j

免责声明:这与我问的另一个问题有关here 。建议我提出一个新问题,而不是更新那个问题,我希望这是正确的。如果不是,请告诉我并忽略这个问题。

我一直在尝试在 Microsoft Azure 中使用 Neo4j,使用 this tutorial 。我创建了一个运行 Linux 和 neo4j 的 VM。我知道他工作得很好,因为我已经能够通过网络管理门户访问数据库,我可以在其中创建和删除条目。然而,当我尝试使用 node.js 插入元素时,问题就出现了。

这是脚本的代码:

    function insert(item, user, request) {
    //comment to trigger .js creation
    var neo4j = require('neo4j');
    var db = new neo4j.GraphDatabase('http://<username>:<password>@neo4jmobile.cloudapp.net:7474');
    var node = db.createNode({ name: item.name });
    node.save(function (err, node) {
        if (err) {
            console.error('Error saving new node to database:', err);
        }
        else {
            console.log('Node saved to database with id:', node.id);
        }
    });

    request.execute();

}

我收到此错误消息:

Error saving new node to database: { [Error: connect ETIMEDOUT]
  stack: [Getter/Setter],
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  __frame:
   { name: 'GraphDatabase_prototype__getRoot__1',
     line: 76,
     file: '\\\\10.211.156.195\\volume-0-default\\bf02c8bd8f7589d46ba1\\4906fa4587734dd087df8e641513f602\\site\\wwwroot\\App_Data\\config\\scripts\\node_modules\\neo4j\\lib\\GraphDatabase.js',
     prev:
      { name: 'GraphDatabase_prototype_getServices__2',
        line: 99,
        file: '\\\\10.211.156.195\\volume-0-default\\bf02c8bd8f7589d46ba1\\4906fa4587734dd087df8e641513f602\\site\\wwwroot\\App_Data\\config\\scripts\\node_modules\\neo4j\\lib\\GraphDatabase.js',
        prev: [Object],
        active: false,
        offset: 5,
        col: 12 },
     active: false,
     offset: 5,
     col: 12 },
  rawStack: [Getter] }

如有任何帮助,我们将不胜感激!

最佳答案

您的网址仍然错误:http://<username>:<password>@http://neo4jmobile.cloudapp.net:7474应该是http://<username>:<password>@neo4jmobile.cloudapp.net:7474

在引用教程(顺便说一句,这非常好)中,他说:

var db = new neo4j.GraphDatabase('http://<username>:<password>@<your neo url>.cloudapp.net:7474');

其中指的是主机名,即:neo4jmobile

关于node.js - 使用 node.js 发布到 Neo4j 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21379212/

相关文章:

javascript - Node.js 的 REST API 无法同时向自身发出请求

azure - 将 Azure 托管的机器人添加到 Microsoft Teams 开发门户

python - 安装 pip-2.7

.net - 如何查看我的 Azure 辅助角色的诊断跟踪?

mysql - 解析后的数据无法保存到mysql

node.js - "ReferenceError: You are trying to ` 导入 ` a file after the Jest environment has been torn down"与 Mongoose 一起使用 jest 时

neo4j - 使用 neo4jphp 函数 "relateTo"在两个节点之间创建双向关系

neo4j - 如何使用 spring-data-neo4j 配置 neo4j EmbeddedGraphDatabase (现已弃用)?

node.js - 如何在neo4j中运行批处理事务

javascript - moment.js - isBetween() 方法不能始终如一地工作