AWS SAM "No response from invoke container for" wrong function name

1

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 mysampleapi2

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

1 Answer
1
Accepted Answer

Hello,

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

AWS
SUPPORT ENGINEER
Tim_P
answered 2 years ago
  • 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 template.yaml

                Path: '/{proxy+}'

    without the proxy line, the lambda handler just never gets called for some reason

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions