0

I am trying to connect Monetdb database, and I would like to use it with a node.js server app.

I currently set up a VirtualBox environment with monetdb package, as described here, and it works well: https://www.monetdbsolutions.com/solutions/cloud/vm I can connect to this VM with putty with root@localhost:2222, and it works.

However, I cannot find the way to connect to the VM and to my database using node monetdb package: https://www.npmjs.com/package/monetdb

I used: var options = { host : 'localhost', port : 2222, dbname : 'mydb', user : 'root', password : 'monetdb' };

I cannot find the way to make it work. When I use:

var conn = require('monetdb').connect(options , function(err) {
    if (!err) console.log('connected');
});

It does not trigger any error, nor launches any connection.

I think I am missing something when I access to the Virtual machine root@localhost:2222. It works with SSH, but I am not sure the access with monetdb node package is similar.

Is it even possible to connect to this VM from node.js? Maybe I should try another way to try this database with node.

They made a "docker container". I never used that kind of thing, but it may be suitable as well...

Any help on how I can solve this would be a lot appreciated! Thanks very much on this.

Best regards

bobby
  • 674
  • 3
  • 10
  • 14
  • How do you know its not triggering any error? You aren't checking the `err` – Yuri Zarubin Sep 02 '15 at 20:55
  • Thanks for your comment. Sorry actually I am, I simplified the code in the post. It seems monetdb is not triggering an error when there is no connection at a "valid" address, or I don't know how to catch it. – bobby Sep 04 '15 at 09:59

1 Answers1

1

The port 2222 that is linked to port 22 on the virtual machine is for ssh only. The instructions show how to use monetdb on the virtual machine, and not from the host system.

The instruction page mentions:

Alternatively you can create a tunnel over SSH to access the database using the MonetDB MAPI protocol.

So that should be your first attempt. If you are on Linux/Unix or OSX you can set up a tunnel to the default monetdb port like this:

ssh root@localhost:2222 -L 50000:localhost:50000

Alternatively you can use VirtualBox to setup the port forwarding, as explained in the manual in paragraph 6.3.1:

To configure Port Forwarding you can use the graphical Port Forwarding editor which can be found in the Network Settings dialog for Network Adaptors configured to use NAT. Here you can map host ports to guest ports to allow network traffic to be routed to a specific port in the guest.

Now assuming monetdb is running on the virtual host you could connect to it on port 50000 on localhost. You have to check the instructions for username/password, they are probably not the same as the ssh credentials used to set up the tunnel.

Another soluction might be to change the virtualbox config from NAT (where port 2222 on your machine is forwarded to 22 on the virtual computer) to a bridged setup where you can access the virtual machine on its own ip address. This is assuming you have a dhcp server running and dhcp is configured correctly on the virtual os. If this is not the case you need server admin knowledge to get all this set up.

Simon Groenewolt
  • 10,607
  • 1
  • 36
  • 64
  • Thanks for your answer. I tried to do this, but I never manipulated that kind of command. I tried, with 2 ways: - with putty: I think I managed to build the ssh tunnel, but I cannot access in my node.js code afterwards. I don't know if it set-up the password correctly. - Then I tried to integrate it the gruntfile.js that launches the node server, with grunt-ssh or grunt-tunnel-exec. I think it is a better way. Currently I did not manage to make it work. I will continue to try this... It's hard... – bobby Sep 04 '15 at 13:01
  • You can also create a port forward with VirtualBox to guest port 50000. – Hannes Mühleisen Sep 08 '15 at 11:32
  • Thanks for the tip @HannesMühleisen, I've updated my answer. – Simon Groenewolt Sep 09 '15 at 07:34