无法在远程服务器上调试节点应用程序

时间:2019-03-15 09:13:58

标签: node.js debugging intellij-idea remote-debugging

我正在像这样在远程服务器(my-domain.com)上运行Express应用程序:

node --inspect=0.0.0.0:9229 ./server.js

intellij idea中,我设置了debug configuration (Attach Node.js/chrome)

host: my-domain.com
port: 9229

当我单击debug按钮时,出现此错误:

  

来自远程主机的无效响应。请检查   调试配置


我可以使用以下设置在本地主机上调试相同的应用程序:

host: localhost
port: 9229

为什么我不能附加到远程节点应用程序并对其进行调试? intellij idea可以给我更多有关错误的信息吗?

1 个答案:

答案 0 :(得分:0)

我找到了解决我的问题和许多其他问题的好方法,它已经存在了很长时间了,我不使用它! :)

对于我的特殊问题,可以使用ssh tunnels

ssh -L 9221:localhost:9229 user@my-domain.com

现在我可以将节点调试器附加到本地主机:9221。它将所有流量从远程端口9229转发到我的本地9221。

另一个是远程端口转发

只需在/etc/ssh/sshd_config中添加以下行:

GatewayPorts yes

这是

ssh -R 9001:localhost:9000 user@my-domain.com

现在,远程计算机上端口9000上的所有流量都已发送到我的本地节点Express应用程序。我可以调试,做我想做的事

这是我从https://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html

那里得到想法的文章
相关问题