代码之家  ›  专栏  ›  技术社区  ›  Rudy

使用OrientJS模块连接到NodeJS中的OrientDB-“Socket Closed”错误

  •  0
  • Rudy  · 技术社区  · 7 年前

    我可以连接到数据库并通过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)
    

    我不知道该如何处理这个错误,因为数据库似乎运行良好。通过谷歌搜索这个错误,我找不到任何有用的信息;谷歌 " " 只返回一个结果,所以我有点不知所措,如何解决这个问题。

    任何洞察都是非常感激的!

    1 回复  |  直到 7 年前
        1
  •  1
  •   Rudy    7 年前

    经过进一步调查,我找到了问题的根源。

    推荐文章