'FunctionApp in Java: debug via Visual Studio Code - ConnectException

I try to debug a FunctionApp written in Java using Visual Studio Code and I get the following error message:

image desription here

I am using default host.json settings:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to Java Functions",
            "type": "java",
            "request": "attach",
            "hostName": "127.0.0.1",
            "port": 5005,
            "preLaunchTask": "func: host start"
        }
    ]
}

Do you have any idea how to resolve the issue?



Solution 1:[1]

From our end, we tried to debug the Azure Functions Java with the same configuration in launch.json, worked successfully:

enter image description here

tasks.json

{
"version": "2.0.0",
"tasks": [
{
"type": "func",
"command": "host start",
"problemMatcher": "$func-java-watch",
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}/target/azure-functions/AzJavaFuncHttpTrig-1649844396189"
},
"dependsOn": "package (functions)"
},
{
"label": "package (functions)",
"command": "mvn clean package",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

Result:

JavaAFVsCodeDebugging

As Steven-MSFT suggested this similar issue-solution and most of the workarounds say, adding the JAVA_OPTS parameter to the local.settings.json helps you to debug the Azure Functions successfully.

Note: If the issue still persists, please re-open the issue on the GitHub-VSCode-AzureFunctionsJava-Debugger-Issues43180.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 HariKrishnaRajoli-MT