简体   繁体   English

Azure移动服务中的Neo4j

[英]Neo4j in Azure mobile services

I have been trying to use a Neo4j database as my database in an Azure Mobile service. 我一直试图将Neo4j数据库用作Azure移动服务中的数据库。 I was following this tutorial and I cant seem to get it to work. 我正在关注本教程 ,但似乎无法正常工作。 Basically what the tutorial does is: 基本上,本教程的工作是:

  • Creates a VM hosted by Azure, running ubuntu and neo4j. 创建由Azure托管的VM,运行ubuntu和neo4j。
  • Creates an Azure mobile service with an SQL table. 使用SQL表创建Azure移动服务。
  • Writes an insert script for the SQL table that uses node.js to connect to the Neo4j VM and past the data there. 为SQL表编写一个插入脚本,该脚本使用node.js连接到Neo4j VM,并将数据粘贴到该处。

Unfortunately mine does not seem to work. 不幸的是,我的似乎没有用。 The data gets posted to the mobile services SQL table but the script to post to the Neo4j server on the VM does not seem to work. 数据已发布到移动服务SQL表,但是要发布到VM上Neo4j服务器的脚本似乎不起作用。 I also know that the VM is setup correctly because I can connect to it in the Neo4j web admin page. 我也知道该VM已正确设置,因为我可以在Neo4j Web管理员页面中将其连接。

Here is the code for the script: 这是脚本的代码:

    function insert(item, user, request) {
    //comment to trigger .js creation
    var neo4j = require('neo4j');
    var db = new neo4j.GraphDatabase('http://<username>:<password>@http://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();

}

Does any one have any experience with this? 有人对这个有经验么? Is there something wrong with my script? 我的脚本有问题吗? With the tutorials approach? 使用教程的方法? Any help would be appreciated. 任何帮助,将不胜感激。

EDIT: There was a problem with the line: console.err('Error saving new node to database:', err); 编辑:行有问题: console.err('Error saving new node to database:', err); which had to be replace with console.err('Error saving new node to database:', err); 必须用console.err('Error saving new node to database:', err); . However I am now getting this error message: 但是我现在收到此错误消息:

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] }

Once again, any help would be appreciated! 再一次,任何帮助将不胜感激!

Did you enable source control and npm install the neo4j module? 您是否启用了源代码控制并npm安装了neo4j模块?

Miranda 米兰达

Ok I managed to figure it out. 好吧,我设法弄清楚了。 The problem was that the tutorial (and documentation for neo4j for node.js) had a typo. 问题在于该教程(以及针对node.js的neo4j的文档)有错字。 The code should have been console.error() rather than console.err() . 该代码应该是console.error()而不是console.err()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM