【问题标题】:Posting to a Neo4j server using node.js使用 node.js 发布到 Neo4j 服务器
【发布时间】:2014-01-27 19:23:24
【问题描述】:

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

我一直在尝试在 Microsoft Azure 中使用 Neo4j,使用 this tutorial。我创建了一个运行 Linux 和 neo4j 的 VM。我知道他的作品很好,因为我已经能够通过 Web 管理门户访问数据库,在那里我可以创建和删除条目。但是,当我尝试使用 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] }

任何帮助将不胜感激!

【问题讨论】:

  • 能否访问目标Linux服务器的Neo4j浏览器?这在我看来像是防火墙问题。

标签: node.js azure neo4j


【解决方案1】:

您的网址仍然错误:http://&lt;username&gt;:&lt;password&gt;@http://neo4jmobile.cloudapp.net:7474 应该是 http://&lt;username&gt;:&lt;password&gt;@neo4jmobile.cloudapp.net:7474

在参考的教程中(顺便说一句,这非常好)他说:

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

这里指的是主机名,即:neo4jmobile

【讨论】:

  • 我实际上已经改变了这一点,正如我在上一篇文章中所说的那样。我不小心没有在这篇文章中更正它。但我已经解决了这个问题,这不是问题。感谢您抽出宝贵时间回复,我很抱歉我搞砸了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-24
  • 1970-01-01
  • 2015-08-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多