我想连接到 NodeJs 中的 cosmos graph db。实施的样本来自文档。我已将示例更改为连接到模拟器,如下所示:
var Gremlin = require("gremlin-secure");
const client = Gremlin.createClient(
8081,
"localhost", // or 127.0.0.1
{
"session": false,
"ssl": false,
"user": "/dbs/graphdb/colls/graphcollz",
"password": "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
});
console.log('Running Drop');
client.on('error', (err) => {
console.log(err.message);
});
我应该提到,在上述文档中提到:
Gremlin 终结点只能是没有协议/端口号的主机名,例如 mygraphdb.graphs.azure.com(不是https://mygraphdb.graphs.azure.com或 mygraphdb.graphs.azure.com:433)。
因此,db 的端点地址localhost
没有任何协议/端口。此外,ssl 设置为false
防止“自签名证书”错误,并且之前在模拟器中创建了 graphdb 和 graphcollz。
这样,我在尝试执行以下查询时收到以下错误:
client.execute('g.V().drop()', {}, (err, results) => {
if (err) return console.error(err);
console.log(results);
});
错误是:
阅读 ECONNRESET
此外,Node js ECONNRESET帖子无法帮助解决连接到模拟器的问题。
现在,问题是如何通过 NodeJS 连接到 cosmos graph db 模拟器?