Debug mode not starting in SAM Local
Tried starting "-d" mode using invoke and start-api. Both will not listen in debug mode.
Status: Image is up to date for lambci/lambda:go1.x
Mounting dscemails (go1.x) at http://127.0.0.1:3000/collect [POST]
You can now browse to the above endpoints to invoke your functions.
You do not need to restart/reload SAM CLI while working on your functions,
changes will be reflected instantly/automatically. You only need to restart
SAM CLI if you update your AWS SAM template.
Even after sending data, VS Code Debugger still can't connect to any port I set.
Debugging with legacy protocol because Node.js version could not be determined (Error: connect ECONNREFUSED 127.0.0.1:5858)
@bscott Is this still occurring in version 0.3.0? This should be addressed and work as expected.
Will leave open for a couple days. If no response, will close
Yes, API Gateway in debug mode does not work. Here is the command: sam local start-api --debug-port 5858. Error message: Unable to open debugger port (localhost:5858): java.net.ConnectException "Connection refused(Connection refused)"
However, it works in function locally mode. Here is the command: sam local invoke -d 5858
Starting SAM CLI in debug mode is not sufficient to attach a debugger. You should send a invoke request first to spin up the Docker container, which will make the port available for debugger to attach:
- Start SAM CLI start-api with --debug-port flag
- Send a HTTP request to the endpoint to invoke the Lambda function. At this point, the Docker container is started and your runtime process is waiting for debugger to attach
- Attach debugger thru IDE. this should work.
Feel free to re-open the issue if the above didn't work.
Hi Is it possible to debug SAM Local with compiled languages, such as .NET Core?
Hi,
I am try to debug using the command "sam local invoke -e event.json -d 5858 HelloWorldFunction ". This command shows "Debugger listening on ws://0.0.0.0:5858/e5ee0254-d38b-4f7b-bb3f-b2b318b17493"
Then my lunch.json config is
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach to SAM CLI",
"type": "node",
"request": "attach",
"address": "localhost",
"port": 5858,
// From the sam init example, it would be "${workspaceRoot}/hello-world"
"localRoot": "${workspaceRoot}",
"remoteRoot": "/var/task",
"protocol": "inspector"
}
]
} and then i click play button in VScode UI. It showing errror as "Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858)"
VSCode - 1.38.1 Node runtime is -10.X @sanathkr Please help on this
Hi, I am try to debug using the command "sam local invoke -e event.json -d 5858 HelloWorldFunction ". This command shows "Debugger listening on ws://0.0.0.0:5858/e5ee0254-d38b-4f7b-bb3f-b2b318b17493" Then my lunch.json config is { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Attach to SAM CLI", "type": "node", "request": "attach", "address": "localhost", "port": 5858, // From the sam init example, it would be "${workspaceRoot}/hello-world" "localRoot": "${workspaceRoot}", "remoteRoot": "/var/task", "protocol": "inspector"
} ]} and then i click play button in VScode UI. It showing errror as "Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858)"
VSCode - 1.38.1 Node runtime is -10.X @sanathkr Please help on this
@sanathkr I'm getting the same error, did you solve this somehow?
Hi, I am try to debug using the command "sam local invoke -e event.json -d 5858 HelloWorldFunction ". This command shows "Debugger listening on ws://0.0.0.0:5858/e5ee0254-d38b-4f7b-bb3f-b2b318b17493" Then my lunch.json config is { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Attach to SAM CLI", "type": "node", "request": "attach", "address": "localhost", "port": 5858, // From the sam init example, it would be "${workspaceRoot}/hello-world" "localRoot": "${workspaceRoot}", "remoteRoot": "/var/task", "protocol": "inspector"
} ]} and then i click play button in VScode UI. It showing errror as "Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858)" VSCode - 1.38.1 Node runtime is -10.X @sanathkr Please help on this
@sanathkr I'm getting the same error, did you solve this somehow?
I could solve it by setting the following setting for the localArguments in the sam field:
"localArguments": [
"--container-host-interface=host.docker.internal"
]
Seems that binding to 127.0.0.1 does not work since the container should bind the port to the host interface and not only within the container