【发布时间】:2014-01-27 19:23:38
【问题描述】:
我一直在尝试使用 Neo4j 数据库作为 Azure 移动服务中的数据库。我正在关注this tutorial,但我似乎无法让它工作。基本上本教程的作用是:
- 创建一个由 Azure 托管、运行 ubuntu 和 neo4j 的 VM。
- 使用 SQL 表创建 Azure 移动服务。
- 为使用 node.js 连接到 Neo4j VM 并将数据粘贴到那里的 SQL 表编写插入脚本。
不幸的是,我的似乎不起作用。数据被发布到移动服务 SQL 表,但发布到 VM 上的 Neo4j 服务器的脚本似乎不起作用。我也知道虚拟机设置正确,因为我可以在 Neo4j 网络管理页面中连接到它。
这是脚本的代码:
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();
}
有人有这方面的经验吗?我的脚本有问题吗?用教程的方法?任何帮助将不胜感激。
编辑:行有问题:console.err('Error saving new node to database:', err); 必须替换为console.err('Error saving new node to database:', err);。但是我现在收到此错误消息:
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>@neo4jmobile.cloudapp.net:7474 -
@MichaelHunger 我已经更改了 URL,不幸的是这不是问题。
-
@Chris 我是天蓝色的新手,所以我什至不知道它在那里。谢谢您的帮助。我收到此错误:
TypeError: Object [object Object] has no method 'err' at </table/person.insert.js>:17:25 at __$Node_prototype_save__1你认为你能帮助我吗? :) -
@Chris 我已经解决了这个问题。我需要说
console.error()而不是console.err()。但是我现在有一个新问题。我已经编辑了原始帖子以显示它。
标签: node.js ubuntu azure neo4j azure-mobile-services