Pergunta

I'm trying to set up the WebStorm NodeJS debugger to connect to a NodeJS project hosted on a Vagrant box. I'm coming up with some difficulties.

If I tunnel into the server the traditional way (ie, via Terminal), it all works fine and I'm able to cURL to it, debug it via WebStorm etc.

    ssh -L 5858:127.0.0.1:5858  -N vagrant@10.20.30.40

Once I'd gotten that working, I put the following into my Vagrantfile:

    config.vm.network :forwarded_port, guest: 5858, host: 5858

Unlike before, this still works on the Vagrant box but not on my local machine. When I cURL to it, I get the following error:

    curl: (56) Recv failure: Connection reset by peer

Does anyone have any ideas as to what I'm doing wrong? Is this even possible to configure through the Vagrantfile?

I want to do it through this so my team can connect their debuggers with zero configuration.

Thanks

Foi útil?

Solução

You could try using a provision shell script (tunnel.sh) which would create a remote port forwarding to your machine:

#!/bin/bash

# executed from 'vagrant'
ssh -R 5858:127.0.0.1:5858 me@my-machine

Actually you should put this script in the same folder than your Vagrantfile, and edit the Vagrantfile to add this lines:

Vagrant.configure("2") do |config|
    config.vm.provision "shell", path: "tunnel.sh"
end

This will make Vagrant execute this script every time you execute the command:

vagrant up

Or:

vagrant provision

When trying this, you should delete the port forwarding line in your Vagrantfile.

I didn't try the tunnel, but I actually use provision scripts to configure the vm when it starts, like copying public keys in authorized_keys and similar tasks.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top