我正在使用 OrientJS (v2.2.10) 在 NodeJS (v8.11.3) 中开发一个应用程序,该应用程序将连接到本地托管的 OrientDB (v3.0.6) 数据库并对其进行查询。但是,当我尝试运行我的程序时,每次都会收到“Socket Closed”错误。
我能够连接到数据库并通过 OrientDB 的控制台和 Web 界面查询它,所以我知道可以通过地址http://localhost:2480访问数据库。如果我在命令提示符中运行“netstat -a”,我可以看到端口 2480 正在侦听 TCP 连接。
这是我目前正在运行的代码:
//Import OrientJS driver for OrientDB
var OrientJs = require('orientjs');
//Connect to OrientDB server
var server = OrientJs({
host: "localhost",
port: "2480",
username: "root",
password: "root"
});
//Connect to 'demodb'
var db = server.use({
name: 'demodb',
username: 'root',
password: 'root'
});
console.log("Connected to database")
//Select all entries in 'Castles' table and print to console
db.select().from('Castles').all()
.then(function(result) {
console.log(result);
});
//Close connection to database
db.close();
我收到的错误是:
Unhandled rejection OrientDB.ConnectionError [0]: Socket Closed
at Connection.<anonymous> (C:\Program Files\nodejs\apollo_server\node_modules\orientjs\lib\transport\binary\connection.js:277:16)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:106:13)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
我不确定如何处理此错误,因为数据库似乎运行良好。通过谷歌搜索此错误,我无法找到任何有用的信息;谷歌搜索“ “ orientjs ”“socket closed” “只返回1个结果,所以我对如何解决这个问题有点茫然。
非常感谢任何见解!