在开启 jpda 启动 tomcat 后,在我的公司,我可以在 eclipse 中远程调试一堆 Web 应用程序。由于多种原因,我现在需要从公司防火墙外部开发和远程调试这些相同的 web 应用程序,并且我只能通过端口 22 上的 ssh 访问该服务器。
我将最需要的端口(svn、nexus、tomcat 本身、从服务器或通过服务器)隧道传输到 localhost,这些服务工作正常,但我无法以任何方式启动 eclipse 调试器;从我第二次尝试开始,我收到“等待数据包 XXX 时连接超时”或“连接被拒绝”。使用服务器上的 nmap 检查,它会在第一次连接尝试之前报告端口打开,然后它会关闭。我在 catalina.out 中没有得到有趣的输出日志
我用来启动隧道的命令是:
ssh -L 8000:localhost:8000 user@mycompany.com
iptables 在服务器和本地机器上都暂时停止以进行测试。
我错过了什么吗?我需要将其他端口转发到本地主机吗?还是以某种方式涉及名称解析?
编辑
在 eclipse 连接尝试之前打开端口:
root@lnxulisse:/opt/apache-tomcat-6.0.32/bin# lsof -p 2147 -n |grep TCP
java 2147 root 4u IPv4 640850 0t0 TCP *:8000 (LISTEN)
java 2147 root 38u IPv6 640859 0t0 TCP *:http-alt (LISTEN)
java 2147 root 40u IPv6 640865 0t0 TCP *:https (LISTEN)
java 2147 root 46u IPv6 640908 0t0 TCP 127.0.0.1:18005 (LISTEN)
java 2147 root 48r IPv6 642625 0t0 TCP 172.24.0.82:48347->172.24.0.82:mysql (ESTABLISHED)
java 2147 root 181u IPv6 640891 0t0 TCP 172.24.0.82:60353->172.24.0.82:mysql (ESTABLISHED)
之后:
java 2147 root 4u IPv6 642769 0t0 TCP 172.24.0.82:48956->172.24.0.82:mysql (ESTABLISHED)
java 2147 root 5u IPv4 640851 0t0 TCP 127.0.0.1:8000->127.0.0.1:34193 (ESTABLISHED)
java 2147 root 38u IPv6 640859 0t0 TCP *:http-alt (LISTEN)
java 2147 root 40u IPv6 640865 0t0 TCP *:https (LISTEN)
java 2147 root 46u IPv6 640908 0t0 TCP 127.0.0.1:18005 (LISTEN)
java 2147 root 181u IPv6 640891 0t0 TCP 172.24.0.82:60353->172.24.0.82:mysql (ESTABLISHED)
返回的确切日食错误是:
Exception occurred during launch
Failed to connect to remote JVM. Connection timed out.
Timeout occurred while waiting for packet 204.
(每次尝试的数据包编号都不同)。
在workspace/.metadata/.log
我得到:
!ENTRY org.eclipse.osgi 2 0 2011-07-17 18:43:53.024
!MESSAGE While loading class "org.eclipse.core.net.proxy.IProxyService", thread "Thread[main,6,main]" timed out waiting (5000ms) for thread "Thread[Thread-6,5,main]" to finish starting bundle "org.eclipse.core.net_1.2.1.r35x_20090812-1200 [232]". To avoid deadlock, thread "Thread[main,6,main]" is proceeding but "org.eclipse.core.net.proxy.IProxyService" may not be fully initialized.
!STACK 0
org.osgi.framework.BundleException: State change in progress for bundle "reference:file:plugins/org.eclipse.core.net_1.2.1.r35x_20090812-1200.jar" by thread "Thread-6".
at org.eclipse.osgi.framework.internal.core.AbstractBundle.beginStateChange(AbstractBundle.java:1073)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:278)
[...]
!ENTRY org.eclipse.ui.ide 4 4 2011-07-17 18:43:53.028
!MESSAGE Proxy service could not be found.
eclipse 配置为直接连接互联网。
编辑 2
我认为解决方案可能在这里:
http://blog.cantremember.com/debugging-with-jconsole-jmx-ssh-tunnels/
但我在理解他的 JNDI/RMI 设置以及在多大程度上适用于我的配置时遇到了一些麻烦。
编辑 3
这是对那些回答“使用<lan|local ip address>
而不是<localhost>
”的人的澄清
- 电脑A:我在公司的工作站
- 电脑B:我家的工作站
- 计算机C:运行tomcat的服务器
B 和 C 在同一网络基础设施中的两个不同子网络中;只允许从外部连接到 C 的端口 22(并且有点“代理”,我不知道网络内部情况)。
A 是“外部”(我的 dsl 连接与动态 IP 地址)。
Debugging on C from B via ssh tunnel -> works
Debugging on C from A via ssh tunnel -> connection timed out while waiting for packet XXX