Java 握手失败 - 在 Intellij 中调试 Solr 时连接过早关闭错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30858312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Handshake failed - connection prematurally closed error when debugging Solr in Intellij
提问by donthurtme
So i was going to debug my Solr filter plugins on Intellij Community Edition. After i ran the program from comand prompt with this command
所以我打算在 Intellij Community Edition 上调试我的 Solr 过滤器插件。在我使用此命令从命令提示符运行程序后
java -jar start.jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8983
I started my Intellij debugger with this config:
我用这个配置启动了我的 Intellij 调试器:
Transport : socket
Debugger mode : attach
Host : localhost
Port : 8983
But when I ran the debugger I got this error:
但是当我运行调试器时,我收到了这个错误:
Error running Debugger: Unable to open debugger port (localhost:8983):
java.io.IOException "handshake failed - connection prematurally closed"
Any idea how to fix this?
知道如何解决这个问题吗?
采纳答案by donthurtme
It should be something like this,
应该是这样的
java "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8983" -jar start.jar
java "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8983" -jar start.jar
it's working now
它现在工作
回答by llogiq
You forgot to specify -Xdebug
on the java
command line.
您忘记-Xdebug
在java
命令行上指定。
Edit: As in
编辑:如
java -jar start.jar -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8983
回答by LazerBass
I got that error when trying to access to debug port on a Docker container.
尝试访问 Docker 容器上的调试端口时出现该错误。
If you are trying to access the debug port inside a Docker container make sure you are specifying the port as *:5005
如果您尝试访问 Docker 容器内的调试端口,请确保将端口指定为 *:5005
E.g.
例如
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
This has been changes since Java 9.
自 Java 9 以来,这已经发生了变化。
See: REGRESSION: Remote debugging does not work on JDK 9
It's not a bug. It's a security.
Before the JDK-8041435
If you have a server with EXT and INT interfaces and start Java process with address=5900 it binds to both interfaces and allow anybody from entire world to connect to your java process unless you block it on firewall.
After JDK-8041435 socket transport try to guess localhost and bind to localhost only. I.e. socket transport by default works only if both client and server are located on the same machine. It's not an easy task to guess proper localhost. so ever same-machine configuration might not work in some situation because of network setup.
You can restore old, insecure behavior using * (asteric) i.e. -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5900 should work exactly as it was before JDK-8041435
But it's recommended to explicitly specify ip address to bind when it possible.
这不是一个错误。这是一种安全。
JDK-8041435 之前
如果您有一台带有 EXT 和 INT 接口的服务器,并以地址 = 5900 启动 Java 进程,它将绑定到这两个接口,并允许全世界的任何人连接到您的 Java 进程,除非您在防火墙上阻止它。
在 JDK-8041435 套接字传输后尝试猜测 localhost 并仅绑定到 localhost。即默认情况下套接字传输仅在客户端和服务器位于同一台机器上时才有效。猜测正确的本地主机不是一件容易的事。因此,由于网络设置,在某些情况下,同一台机器的配置可能无法正常工作。
您可以使用 * (asteric) 恢复旧的、不安全的行为,即 -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5900 应该像 JDK-8041435 之前一样工作
但建议在可能的情况下明确指定要绑定的 ip 地址。
And JDWP socket connector accept only local connections by default
The JDWP socket connector has been changed to bind to localhost only if no ip address or hostname is specified on the agent command line. A hostname of asterisk (*) may be used to achieve the old behavior which is to bind the JDWP socket connector to all available interfaces; this is not secure and not recommended.
JDWP 套接字连接器已更改为仅在代理命令行上未指定 ip 地址或主机名时绑定到 localhost。可以使用星号 (*) 主机名来实现旧行为,即将 JDWP 套接字连接器绑定到所有可用接口;这不安全,不推荐。