AWS SAM “调用容器时没有响应”错误的函数名称

0

【以下的问题经过翻译处理】 我已经调试了我的应用程序,发现了一个问题。我有 2 个 REST API Gateway,看来由于它们都绑定在同一个端点上,第一个将收到第二个应该处理的调用。

这是我的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: c 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 ''' 当我发送一个针对'mysampleapi2'的HTTP请求时 使用启动命令在日志中显示如下: 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

为什么我的'mysampleapi2'没有接收到HTTP请求?如果我在不同的端口上使用不同的模板文件运行它们,那么它将正常工作...为什么会这样?

转发我在 StackOverflow 上的问题: https://stackoverflow.com/questions/72036152/aws-sam-no-response-from-invoke-container-for-wrong-function-name

1 Antwort
0

【以下的回答经过翻译处理】 你好,

看起来在日志中你可能在调用函数 mysampleapi1。然而,似乎仍然存在函数超时的问题。

我测试了一个会导致函数超时的场景,并收到了相同类型的错误消息。所以这里可能有两种情况:

  • 你可能在调用错误的API
  • 你的Lambda函数可能已经超时

当然,也可能是其他问题,比如特定于Docker的问题。如果可以的话,请在AWS SAM CLI Github repo上分享这个问题,那里的开发人员会遇到许多使用SAM CLI的问题,并且可能能够在我提到的这些项目之外快速找到解决方法。这是提出问题的链接:https://github.com/aws/aws-sam-cli/issues

profile picture
EXPERTE
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen