远程调试时 Eclipse 连接被拒绝

Eclipse connection refused when remote debugging

我一直在学习本教程 how to setup remote debugging。 我的 Jar 运行 调试模式在我的服务器上侦听端口 6065,设置如下:

-Xrunjdwp\:transport\=dt_socket,server\=y,address\=6065,suspend\=n

我在调试模式下使用 jar 在我的服务器上启动 JAR:

myApplicationThatContainsJar.exe -debug "my application"

>     Now Starting JVM
>     Listening for transport dt_socket at address: 6065

我安装了用于 ping (IP 地址:端口) 的 psping 工具。我可以从我的开发箱中 ping 我的 ipaddress 示例:44.66.33.66:6065 并得到回复。但是当我尝试在 Eclipse 中启动远程调试时,我得到:

Failed to connect to remote VM. Connection refused. Connection refused: connect

我已经确认我已经在我的 DEV 盒和服务器上为该端口添加了入站和出站流量权限。

当我在我的服务器上启动我的 JAR 时,在我尝试连接 Eclipse 之前我做了一个:

psping 44.66.33.66:6065 

我收到回复说发送和接收的损失率为 0%,这意味着我确实收到了回复。

在 'Debug Configurations' window 中的 eclipse 调试配置中,我正确列出了主机和端口以及 'Connection Type: Standard(Socket Attach)'.

当我尝试与 Eclipse 连接并收到连接被拒绝错误时,我再次尝试从命令行进行 psping,但现在 Eclipse 对连接做了一些事情,我进入了命令行:

The remote computer refused the network connection.

有什么建议我还应该检查哪些地方?或者我还应该在哪里排除故障?我正在尝试对我的 JAR 从开发箱到我的服务器进行远程调试。

-Xrunjdwp\:transport\=dt_socket,server\=y,address\=6065,suspend\=n

应该是:

-Xrunjdwp\:transport\=dt_socket,server\=y,address\=6065,suspend\=y

注意 suspend\=y 请记住,我需要转义 equals 而其他人可能不需要这样做。一旦我设置为 suspend\=y,应用程序就会等待我从 eclipse 连接,然后我就可以开始远程调试了。

不要忘记为您用于 address\=6065

的端口打开入站和出站流量
Check network setting in VM and set Attached to: Bridged Adapter
Check VM IP using ipconfig command
Run Java Application using following command
> java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n myapp
Above command myapp replace to your application name
In eclipse go to debug configuration -> remote java Application -> New
Host: remote VM ip
Port: given port that given in command
Apply -> Debug