Debugger failed to attach: handshake failed - received >OPTIONS

Hello,
I am new to play framework, I am trying to start debugger on my local by running sbt -jvm-debug 9999 and get following error:
[APIServices3.0] $ Debugger failed to attach: handshake failed - received >GET /reflectio< - expected >JDWP-Handshake<
Debugger failed to attach: handshake failed - received >GET /reflectio< - expected >JDWP-Handshake<

Can you guys please help me to fix this problem? Thank you!

When you gave that port 9999, did it actually start listening on that port?

Listening for transport dt_socket at address: 9999

Sorry, yes it did, there was message saying that it listens to port 9999. I see this error every time I call the API

This looks like the debug port is receiving HTTP requests. Note that port 9999 in this example is only used to connect a remote Java debugger (such as from your IDE). The HTTP server will run on another port (9000 by default).

1 Like

Thank you Tim, yes it seems like server running on default port 9000. How can I attach debugger to debug my application?

You can add the following to your IDE command line params to attach debugger

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999

suspend=y will force the server to wait till a process connects.
With suspend=n server will not wait for process to attach.

Thank you Aditya, but I got same error I use Visual Studio Code IDE, I run that command in terminal window but still got same error.

java -agentlib:jdwp=transport=dt_socket,address=localhost:9999,server=y,suspend=y
Listening for transport dt_socket at address: 9999
Debugger failed to attach: handshake failed - received >OPTIONS /searc< - expected >JDWP-Handshake<
Debugger failed to attach: timeout during handshake

Is there something else using this port already? For example, what is the output or running lsof -i :9999? What if you try another port instead of 9999? Is there a firewall that could be possibly blocking the bind to this port?

Nope nothing is running on that port only the debugger:

>netstat -ano | findStr "9999"
  TCP    127.0.0.1:9999         0.0.0.0:0              LISTENING       50940

Can you try changing the debugger port and see if it helps?