I am trying to connect to OriendDB(v2.0.13) using Orientjs(v2.0.0) on NodeJS(v0.12.2) like so:
var OrientDB = require('orientjs');
var orientDBServer = OrientDB({
host: 'localhost',
port: 2424,
username: 'orientdb',
password: 'orientdb'
});
var database = orientDBServer.use({
name: 'thermos',
username: 'orientdb',
password: 'orientdb'
});
As soon as I make a query, for example:
database.select().from('OUser').all()
.then(function(result) {
console.log(result);
});
I'm getting this error.
Unhandled rejection OrientDB.ConnectionError [1]: Remote server closed the connection. at Connection.handleSocketEnd (/usr/share/adafruit/webide/repositories/my-pi-projects/Thermostat/node_modules/orientjs/lib/transport/binary/connection.js:320:9) at Socket.emit (events.js:104:17) at _stream_readable.js:908:16 at process._tickCallback (node.js:355:11)
I tried different query just to make sure I'm not doing a mistake myself and I also tried via studio and the console directly on the server which worked fine. (using the same logins...)
What can possibly cause this error? Thanks
Update I made a second nodejs server and now I can successully make requests on the database that is installed on the first server. I'll investigate if there is some sort of weird permission that blocks localhost or if node is missing some kind of permission...(first server is running raspbian)
I don't think you have to specify the username and password again for the use function. My database config file looks like this and it works like a charm :
var OrientDB = require('orientjs');
var server = OrientDB({
host:'localhost',
port:2424,
username: 'root',
password: 'root'
});
module.exports = server.use('databaseName');
Also, make sure that you created the database with the account you are using. Otherwise, it won't work.
If this still doesn't work, it could be a bug. I would personally try recreating the database...