免责声明:这与我问的另一个问题有关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/