Unable to open debugger port java io ioexception handshake failed connection prematurally closed

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting ‘Unable to open debugger port’ again and again #569

Getting ‘Unable to open debugger port’ again and again #569

Comments

Hi
I started using this great plugin on top of Intellij but I often get the following message:

Error running ‘port 8700’: Unable to open debugger port (localhost:8700): java.net.ConnectException «Connection refused: connect«

Error running ‘port 8700’: Unable to open debugger port (localhost:8700): java.io.IOException «handshake failed — connection prematurally closed«

Sometimes it does run but on the wrong process (The monitor shows the debug symbol on the Whatsapp process or some other app).
When I try to use the process’s port it also shows me the ‘connection refused’ error message.
I made it worked once or twice and the debugger worked well too but most of the times it shows me those errors.

Читайте также:  Php exception error codes

STR:
Follow the instructions in the readme page.

My idea: Intellij 2017.2.5 on Windows 64 bit.
Debugging device: OnePlus 3T — LineageOS 14.1
Monitor Version: 25.2.2

The text was updated successfully, but these errors were encountered:

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

paketo-buildpacks / debug Public archive

Can’t start a remote JVM debug session from my IDEA: «handshake failed — connection prematurally closed» #43

Can’t start a remote JVM debug session from my IDEA: «handshake failed — connection prematurally closed» #43

Comments

What happened?

I’m using pack and Paketo buildpacks for building OCI containers for my Spring Boot applications (version 2.4.6).
To clarify I’m not using the Spring Boot Maven plugin to create an OCI image for my applications.
The applications are built using Maven and Java 11 and are running in the OCI container using JRE 11.
Yesterday I ran into the issue of not being able to start a remote JVM debugging session from IntelliJ to a running container.

  • Steps to reproduce
  1. Make sure to have Java JDK 11 installed (I’m using 11.0.11, vendor: AdoptOpenJDK)
  2. Create a simple Spring Boot Application (version 2.4.5, Java version 11 with Spring Web dependency)
  3. Build the project: ./mvnw clean package
  4. Build the OCI container using pack with debug enabled: pack build application/demo —builder paketobuildpacks/builder:base —path target/demo-0.0.1-SNAPSHOT.jar —env BP_JVM_VERSION=11 —env BP_DEBUG_ENABLED=true
  5. Start the container: docker run —rm —tty —publish 8080:8080 —publish 8000:8000 —env BPL_DEBUG_ENABLED=true application/demo
  6. From the IDEA start a remote JVM debug session:

Error running ‘Remote Debug’: Unable to open debugger port (:8000): java.io.IOException «handshake failed — connection prematurally closed»

The Spring Boot application output log:

Setting Active Processor Count to 4 Calculating JVM memory based on 7074784K available memory Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx6477722K -XX:MaxMetaspaceSize=85061K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 7074784K, Thread Count: 250, Loaded Class Count: 12604, Headroom: 0%) Adding 129 container CA certificates to JVM truststore Spring Cloud Bindings Enabled Debugging enabled on port 8000 Picked up JAVA_TOOL_OPTIONS: -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -agentpath:/layers/paketo-buildpacks_bellsoft-liberica/jvmkill/jvmkill-1.16.0-RELEASE.so=printHeapHistogram=1 -XX:ActiveProcessorCount=4 -XX:MaxDirectMemorySize=10M -Xmx6477722K -XX:MaxMetaspaceSize=85061K -XX:ReservedCodeCacheSize=240M -Xss1M -Dorg.springframework.cloud.bindings.boot.enable=true -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n Listening for transport dt_socket at address: 8000 . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.4.6) 

When I downgrade the Spring Boot application to Java 8.

pack build application/demo —builder paketobuildpacks/builder:base —path target/demo-0.0.1-SNAPSHOT.jar —env BP_JVM_VERSION=8 —env BP_DEBUG_ENABLED=true

and start the OCI container:

docker run —rm —tty —publish 8080:8080 —publish 8000:8000 —env BPL_DEBUG_ENABLED=true application/demo

I can start the remote JVM debug session without any problem:

Connected to the target VM, address: ‘:8000’, transport: ‘socket’

The workaround I use now is to use Java 11 and build without the BP_DEBUG_ENABLED=true flag but add JVM remote debug settings myself using the JAVA_TOOL_OPTIONS:

docker run —rm —tty —publish 8080:8080 —publish 8000:8000 —env JAVA_TOOL_OPTIONS=»-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000″ application/demo

I expect to be able to start a remote JVM debug session using Java 11 or later.

The actual behavior: Can start a remote JVM debug session.
Error from IntelliJ:

Error running ‘Remote Debug’: Unable to open debugger port (:8000): java.io.IOException «handshake failed — connection prematurally closed»

Build Configuration

OS: Mac OS X, version: 10.15.7, arch: x86_64
Maven version: Apache Maven 3.6.3
Java version: 11.0.11, vendor: AdoptOpenJDK

  • What platform ( pack , kpack , tekton buildpacks plugin, etc.) are you
    using? Please include a version.

Pack version: 0.14.2+git-0fd189d.build-1450

Paketo CA Certificates Buildpack 2.2.0
Paketo BellSoft Liberica Buildpack 8.0.0
Paketo Executable JAR Buildpack 5.0.0
Paketo Spring Boot Buildpack 4.3.0
Paketo Debug Buildpack 3.0.0

To me it looks like the debug buildpack is not taking the difference between Java 8 and Java 11 command line arguments into account:

Java 8:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000

Checklist

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.

The text was updated successfully, but these errors were encountered:

Источник

Java – Handshake failed – connection prematurally closed error when debugging Solr in Intellij

I got that error when trying to access to debug port on a Docker container.

If you are trying to access the debug port inside a Docker container make sure you are specifying the port as *:5005

This has been changes since Java 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.

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.

Источник

Оцените статью