orientjs not using the servers list?

66 Views Asked by At

hi I am developing an application in nodejs which uses orientdb.

I am using orientjs version 2.2.10

var OrientDB = require('orientjs');
var server = OrientDB({
    host: '127.0.0.1',
    port: 2424,
    username: 'root',
    password: '123',
    servers: [{
        host: "192.168.0.159",
        port: 2425
    }],
});

server.connect().then(() => {
    console.log("connected");
}).catch(err => {
    console.log(err);
})

above is a simple code to check whether the driver connects to the server. however when there is no orientdb instance running in localhost i get the connection refused error. it looks like that when connecting it first tries host in main object and never tries to connect to hosts in servers array. I have also tried orientjs v3, result is the same.

can someone tell me what could be the issue here? thanks

1

There are 1 best solutions below

0
Rahul Patil On

You can try like this:

databaseConfig = {
            "host": '127.0.0.1',
            "port": 2424,
            "username": 'root',
            "password": 132,
            "name": 'databaseName',
            "user": 'root'
        };
let server = OrientDB(databaseConfig);
let db = server.use(databaseConfig);
db.open()
    .then(()=>{
         console.log('Connected!')
     });