使用 unix 文件套接字从 nodejs 连接到 arangodb3
connect from nodejs to arangodb3 using unix file socket
我正在尝试使用 Nodejs 7.5.0 和 Gentoo 上的 unix 文件套接字连接到 arangodb3 Linux。
我在 /tmp/mysocket.
使用 unix 套接字启动了 arrangodb3 服务器
我尝试了两个不同的模块:
const arangojs = require('arangojs');
let db = arangojs({
url: `unix:///tmp/mysocket`,
databaseName: false // don't automatically append database path to URL
});
db.createDatabase('mydb', function (err, info) {
if (err) console.error(err.stack);
else {
console.info('database created');
// database created
}
});
这给了我:
Error: connect ECONNREFUSED ::1:80
at Object.exports._errnoException (util.js:1023:11)
at exports._exceptionWithHostPort (util.js:1046:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
所以它尝试连接到本地主机端口 80,忽略我的 unix 套接字文件位置
我也试过:
var arango = require('arango');
var db = arango.Connection("unix:///tmp/mysocket");
db.collection.list().done(function(res){
console.log("collections: %j", res);
});
这给了我:
Error: Cannot find module 'unix'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Xhr (/home/ufk/work-projects/bingo/arrango/node_modules/arango/lib/xhr.js:23:12)
at Arango.request (/home/ufk/work-projects/bingo/arrango/node_modules/arango/lib/arango.js:166:2)
at Arango.(anonymous function) [as get] (/home/ufk/work-projects/bingo/arrango/node_modules/arango/lib/arango.js:204:14)
at Object.list (/home/ufk/work-projects/bingo/arrango/node_modules/arango/lib/api/collection/index.js:125:16)
at Object.instance.(anonymous function) [as list] (/home/ufk/work-projects/bingo/arrango/node_modules/arango/lib/api/api.js:121:25)
at Object.<anonymous> (/home/ufk/work-projects/bingo/arrango/index2.js:5:16)
我真的不在乎使用哪个模块.. 只是在寻找支持 unix 文件套接字的东西。有什么想法吗?
我在 arrangojs 上打开了一个关于缺乏对 unix 文件套接字的支持的错误报告。他们回答说不支持。 unix://
尚不支持,但 nodejs 的 http.request
支持 socketPath
参数。
- 问题:https://github.com/arangodb/arangojs/issues/405
- socketPath 相关文档:https://nodejs.org/api/http.html
我正在尝试使用 Nodejs 7.5.0 和 Gentoo 上的 unix 文件套接字连接到 arangodb3 Linux。
我在 /tmp/mysocket.
使用 unix 套接字启动了 arrangodb3 服务器我尝试了两个不同的模块:
const arangojs = require('arangojs');
let db = arangojs({
url: `unix:///tmp/mysocket`,
databaseName: false // don't automatically append database path to URL
});
db.createDatabase('mydb', function (err, info) {
if (err) console.error(err.stack);
else {
console.info('database created');
// database created
}
});
这给了我:
Error: connect ECONNREFUSED ::1:80
at Object.exports._errnoException (util.js:1023:11)
at exports._exceptionWithHostPort (util.js:1046:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
所以它尝试连接到本地主机端口 80,忽略我的 unix 套接字文件位置
我也试过:
var arango = require('arango');
var db = arango.Connection("unix:///tmp/mysocket");
db.collection.list().done(function(res){
console.log("collections: %j", res);
});
这给了我:
Error: Cannot find module 'unix'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Xhr (/home/ufk/work-projects/bingo/arrango/node_modules/arango/lib/xhr.js:23:12)
at Arango.request (/home/ufk/work-projects/bingo/arrango/node_modules/arango/lib/arango.js:166:2)
at Arango.(anonymous function) [as get] (/home/ufk/work-projects/bingo/arrango/node_modules/arango/lib/arango.js:204:14)
at Object.list (/home/ufk/work-projects/bingo/arrango/node_modules/arango/lib/api/collection/index.js:125:16)
at Object.instance.(anonymous function) [as list] (/home/ufk/work-projects/bingo/arrango/node_modules/arango/lib/api/api.js:121:25)
at Object.<anonymous> (/home/ufk/work-projects/bingo/arrango/index2.js:5:16)
我真的不在乎使用哪个模块.. 只是在寻找支持 unix 文件套接字的东西。有什么想法吗?
我在 arrangojs 上打开了一个关于缺乏对 unix 文件套接字的支持的错误报告。他们回答说不支持。 unix://
尚不支持,但 nodejs 的 http.request
支持 socketPath
参数。
- 问题:https://github.com/arangodb/arangojs/issues/405
- socketPath 相关文档:https://nodejs.org/api/http.html