Search code examples
javaazuredebuggingvisual-studio-codeazure-functions

Azure Functions. Debugging java from VS Code. Can not connect to a debugee VM


did anyone faced with such problem. Have an Azure Functions app (beta-2 plugin version used). After app started I receive an error that VSCode failed attach to remove debuggee VM. Reason: Connection Refused.

I have VSCode with the following plugins installed: ms-azuretools.vscode-azurefunctions, vscjava.vscode-java-debug, vscjava.vscode-java-pack, vscjava.vscode-maven, redhat.java

launch.json contains following configuration:

`{
    "name": "Attach to Java Functions",
    "type": "java",
    "request": "attach",
    "hostName": "localhost",
    "port": 5005,
    "preLaunchTask": "runFunctionsHost"
}`

runFunctionsHost contains following script: mvn clean package -B; func host start --debug VSCode --script-root ....

OS: windows


Solution

  • The solutions is to add "JAVA_OPTS" parameter into the local.settings.json with the value like that "-Djava.net.preferIPv4Stack=true -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=127.0.0.1:5005"