handshake failed error with Remote Debugging

Answered

Hi,
When I try remote debugging on my mac it work without any problem but when I'm try it from on local vagrant box machine i got the following exception in the event log

Error running retailapp: Unable to open debugger port : java.io.IOException "handshake failed - connection prematurally closed"

i used the following command to run the jar on the local vagrant box

    $ java -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar myjar.jar

That is after i have made prot forwarding for the fort 5005 in the Vagrantfile

    override.vm.network "forwarded_port", guest: 5005, host: 5005, protocol: 'tcp' # InteliJ Debugger

and used the following remote configuration on IntelliJ

Screen Shot 2014-06-24 at 4.29.47 PM.png
17 comments
Comment actions Permalink

Hi Everyone,

 

Did you solve this problem? I've got same error now. If you solved, could you please help me to solve.

 

Thank you

 

 

0
Comment actions Permalink

The error you described is completely different: 

The initial error: 

"handshake failed - connection prematurally closed"

Your error: 

Unable to open debugger port (localhost:5005): java.net.ConnectException "Connection refused: connect"

In your case, remote debugger needs to connect to the JVM that is already running in debug mode. Make sure you start the app you want to debug first with the JVM options suggested by the IDE. Then start Remote configuration to connect and debug this app.

Also, make sure that localhost is configured in your hosts file like that: 

127.0.0.1 localhost
0
Comment actions Permalink

Hi Konstantin, 

Thank you for your kind reply.

You're right. When I choose port address other than 5005 I've got above error. But when I used 5005 I've got following error. 

 

 

 

0
Comment actions Permalink

No! it is not inside Docker.

0
Comment actions Permalink

May you show the command how the application is started?

0
Comment actions Permalink

I am using debug button instead command for starting application. 

When I clicked debug button I've got error with above settings. 

0
Comment actions Permalink

This configuration (RemoteDebug) is used to connect to an already running process. In case you want to start an application in debug mode, please use "Application" Run/Debug configuration: 

https://www.jetbrains.com/help/idea/debugging-your-first-java-application.html

0
Comment actions Permalink

Konstantin,

Really, I appreciate for your patience.

I can give info briefly about my project and what we wanted to do. We have project running on openshift and I want to debug that project via IntelliJ. When I search on the Internet, I've found above settings to apply and I applied. But I've got error as we've mentioned before.

 

Thank you again.

 

 

 

0
Comment actions Permalink

Ah, I see. AFAIK, OpenShift is also a containerization solution like docker, Virtuozzo, etc. So, the same solution is valid here. 

Let me describe the situation as I see it: 

A java application runs inside the OpenShift container. This Java application is started with some arguments like that: 

java '-<some options here>,address=5005' SomeApplication

In case of running the application using this command, the application's debugger will accept connections only from the localhost (from the container itself). But in your case the debugger should accept connections from IntelliJ IDEA (this is another host from container's point of view). To pass the information that connections should be accepted from anywhere including IntelliJ IDEA, it is needed to change address=5005 with address=*:5005.

You need to go into the openshift container with your application and edit application's configuration file, so it would start like that: 

java '-<some options here>,address=*:5005' SomeApplication
1
Comment actions Permalink

I am trying both of them. But error is still continue. 

Firstly, I built project successfully. Then I typed following command to terminal and entered. Project started successfully. I expected to see message like "Listening for transport dt_socket at address 5005". But I didnt see message.

java -jar -Dspring.profiles.active=dev -Dspring-boot.run.jvmArguments="-Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" myproject-0.0.1-SNAPSHOT.jar

After started project then I clicked debug button, unfortunately I had same error.

Also, I watched youtube video at following address and I did the completely same thing;

https://www.youtube.com/watch?v=jA1wHbAK_T0

 

At the end I've two issue; one of this is not see message like "Listening for transport dt_socket at address 5005",

and other is 

 

0
Comment actions Permalink

Please change the address in your command as I stated in the previous message: 

Your (address=5005): 

java -jar -Dspring.profiles.active=dev -Dspring-boot.run.jvmArguments="-Xdebug -gentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" myproject-0.0.1-SNAPSHOT.jar

Needed (address=*:5005): 

java -jar -Dspring.profiles.active=dev -Dspring-boot.run.jvmArguments="-Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" myproject-0.0.1-SNAPSHOT.jar
1
Comment actions Permalink

I've changed. But the error still continues.

0
Comment actions Permalink

Can you show the output of the netstat command from inside the container once the application is started? It is needed to check that debugger is listening on all interfaces. In case container is linux-based, that should look like that: 

# netstat -tpln | grep 5005

tcp 0 0 0.0.0.0:5005 0.0.0.0:* LISTEN 29196/java
0
Comment actions Permalink

I am using windows ;

netstat -aon | findstr "5005"
TCP 127.0.0.1:5005 0.0.0.0:0 LISTENING 8052
0
Comment actions Permalink

Am I right that Windows is the OS where IntelliJ IDEA is installed? And your application is running inside OpenShift container (which is most probably running some kind of Linux)? If so, please check the output of netstat inside the OpenShift container. 

0
Comment actions Permalink

Yes you're right.  But I couldn't use netstat command. When I used I've got "command not found". How can I check the output of netstat inside the OpenShift container?

0

Please sign in to leave a comment.