Error running 'remote_debug': Unable to open debugger port (localhost:4004): java.io.IOException "handshake failed – connection prematurally closed"

huangapple go评论121阅读模式
英文:

Error running 'remote_debug': Unable to open debugger port (localhost:4004): java.io.IOException "handshake failed - connection prematurally closed"

问题

以下是翻译好的内容:

我在尝试从IntelliJ IDEA连接到远程JVM调试端口时遇到以下错误。
注意:我在我的IntelliJ IDEA项目中使用Java 17,并且还有一个带有Java 17环境的Docker镜像。

错误信息:

Error running 'remote_jvm_debug': 无法打开调试器端口 (localhost:4004): java.io.IOException "握手失败 - 连接意外关闭"

在Dockerfile中,我使用以下环境配置:

ENV JAVA_TOOL_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=*:4004,server=y,suspend=n"

我还尝试在Dockerfile中使用以下环境变量,但没有成功:

ENV JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=0.0.0.0:4004,server=y,suspend=n"

为了在我运行Docker容器的远程服务器上建立隧道,我使用以下命令:

ssh -f 10.12.91.11 -L 4004:127.0.0.1:4004 -N

在我的docker-compose.yml文件中,我有以下端口和环境配置:

    ports:
      - "8002:80"
      - "4004:4004"
    environment:
      JVM_ARGS: *jvmflags
      CATALINA_OPTS_EXTRA: *jvmflags

我还尝试在Dockerfile中使用以下环境变量,这是在StackOverflow和其他地方推荐的,但在我的情况下不起作用:

ENV JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:4004"
英文:

I am getting below error while conneting to remote jvm debug port from intelliJIdea.
Note: I am using Java 17 in my intellijIdea project and also have docker image with Java 17 Env.

Error:

Error running 'remote_jvm_debug': Unable to open debugger port (localhost:4004): java.io.IOException "handshake failed - connection prematurally closed"

In Dockerfile I am using below environment conf:

ENV JAVA_TOOL_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=*:4004,server=y,suspend=n" 

I also tried below ENV in my Dockerfile, but no luck:

ENV JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=0.0.0.0:4004,server=y,suspend=n"

To establish a tunnel on my remote server on which I run docker container, I use below command:

ssh -f 10.12.91.11 -L 4004:127.0.0.1:4004 -N

In my docker-compose.yml file I have below port and ENV conf:

    ports:
      - "8002:80"
      - "4004:4004"
    environment:
      JVM_ARGS: *jvmflags
      CATALINA_OPTS_EXTRA: *jvmflags

I tried using below ENV in my Dockerfile which is suggested on stackoverflow and other places, but its not working in my case:

ENV JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:4004"

答案1

得分: 0

让我回答我的问题,在阅读了互联网上提供的一些链接并尝试了一些配置后,我成功地在运行在Docker环境上的Java 17 Spring Boot应用程序上启用了远程JVM调试。

您需要在docker-compose.yml的环境配置下添加以下环境变量:

JAVA_OPTS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:4003"

同时,如果在docker-compose.yml文件中存在任何旧的Java 8环境变量,您需要将它们注释掉:

#JVM_ARGS: *jvmflags
#CATALINA_OPTS_EXTRA: *jvmflags

这里是官方IntellijIdea链接,提供了有关Java 17远程JVM调试配置的详细信息供您参考!享受!😄👍

英文:

Let me answer my own question, after reading some links available on the internet and after trying couple of configurations, I could able to successfully enable the remote JVM debug on my Java 17 spring boot application running on Docker environment.

You need to add following env variable under environment configuration in your docker-compose.yml:

JAVA_OPTS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:4003"

And at the same time you will need to comment out any old Java 8 environment variables if they are present in your docker-compose.yml file:

#JVM_ARGS: *jvmflags
#CATALINA_OPTS_EXTRA: *jvmflags

Here is official IntellijIdea link for Java 17 Remote JVM Debug configurations details for your reference! Enjoy!😉 😊

huangapple
  • 本文由 发表于 2023年8月4日 22:53:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76837038.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定