AWS SAM "No response from invoke container for" wrong function name
I've debugged my application, and identified a problem. I have 2 REST API Gateway, and it seems like since they both bind on the same endpoint, the first one will recieve the call that the second one should handle.
Here's my template.yaml
Resources: mysampleapi1: Type: 'AWS::Serverless::Function' Properties: Handler: packages/mysampleapi1/dist/index.handler Runtime: nodejs14.x CodeUri: . Description: '' MemorySize: 1024 Timeout: 30 Role: >- arn:aws:iam:: [PRIVATE] Events: Api1: Type: Api Properties: Path: /users Method: ANY Environment: Variables: NODE_ENV: local Tags: STAGE: local mysampleapi2: Type: 'AWS::Serverless::Function' Properties: Handler: packages/mysampleapi2/dist/index.handler Runtime: nodejs14.x CodeUri: . Description: '' MemorySize: 1024 Timeout: 30 Role: >- arn:aws:iam:: [PRIVATE] Events: Api1: Type: Api Properties: Path: /wallet Method: ANY Environment: Variables: NODE_ENV: local Tags: STAGE: local
When I send a HTTP request for
Here's what's happening in the logs using the startup command
sam local start-api --port 3001 --log-file /tmp/server-output.log --profile personal --debug
2022-04-27 18:2:34,953 | Mounting /home/mathieu_auclair/Documents/Project/repositories/server as /var/task:ro,delegated inside runtime container 2022-04-27 18:20:35,481 | Starting a timer for 30 seconds for function 'mysampleapi1' 2022-04-27 18:21:05,484 | Function 'mysampleapi1' timed out after 30 seconds 2022-04-27 18:21:46,732 | Container was not created. Skipping deletion 2022-04-27 18:21:46,732 | Cleaning all decompressed code dirs 2022-04-27 18:21:46,733 | No response from invoke container for mysampleapi1 2022-04-27 18:21:46,733 | Invalid lambda response received: Lambda response must be valid json
Why is my
mysampleapi2 not picking the HTTP call? If I run them in separate template files using different ports, then it works... why is that?
Re-post from my question on StackOverflow: https://stackoverflow.com/questions/72036152/aws-sam-no-response-from-invoke-container-for-wrong-function-name
it looks like in the logs you're invoking the function
mysampleapi1 possibly. However it appears that its still having a function timeout.
I tested creating a scenario where my function would timeout, and I received the same type of error message. So two things may be occuring here:
- you may be invoking the incorrect API
- your Lambda function may be timing out
Granted it may be something entirely else occurring such as it could be something specific to Docker. If you can, mind sharing this issue on the AWS SAM CLI Github repo? The developers over there come across many types of issues with using the SAM CLI and may be able to quickly find a solution outside of the items I mentioned above. Here's a link to raise a question with the team: https://github.com/aws/aws-sam-cli/issues
After launching my lambda in separate processes, I discovered that there's an issue in my configuration for the second service.
The issue still occured after this launcher
echo "" > /tmp/server-output-1.log sam local start-api --port 3001 --log-file /tmp/server-output-1.log --template .template.1.yaml --debug & tail -f /tmp/server-output-1.log & echo "" > /tmp/server-output-2.log sam local start-api --port 3002 --log-file /tmp/server-output-2.log --template .template.2.yaml --debug & tail -f /tmp/server-output-2.log &
I noticed when I exported my configuration, for one of the services, there's the following in the
without the proxy line, the lambda handler just never gets called for some reason
SAM & Docker Builds-- How do they update (not working for me)?asked 3 months ago
ApiGateway REST not respecting Lambda aliasAccepted Answerasked 5 months ago
Do HTTP APIs have same IAM integrations as REST APIs?Accepted Answerasked 2 years ago
Deploy Lambda Function and API Gateway RESTasked 3 months ago
AWS SAM "No response from invoke container for" wrong function nameAccepted Answerasked 24 days ago
HTTP API - Custom Domain (Regional) - incorrect SSL cert?asked 2 years ago
IPv6 support for API Gateway Custom Domain Namesasked 3 years ago
sam generate-event - How to set isBase64 to false?Accepted Answerasked 5 months ago
Lambda function as image, how to find your handler URIasked 4 days ago
SAM invoke won't take local env varsasked 4 months ago